Commit 40b6e86a99

Lachlan Easton <lachlan@lakebythewoods.xyz>
2020-09-10 12:32:40
zig fmt: fix #6171
1 parent c06674e
Changed files (2)
lib/std/zig/parser_test.zig
@@ -3583,6 +3583,24 @@ test "zig fmt: use of comments and Multiline string literals may force the param
     );
 }
 
+test "zig fmt: single argument trailing commas in @builtins()" {
+    try testCanonical(
+        \\pub fn foo(qzz: []u8) i1 {
+        \\    @panic(
+        \\        foo,
+        \\    );
+        \\    panic(
+        \\        foo,
+        \\    );
+        \\    @panic(
+        \\        foo,
+        \\        bar,
+        \\    );
+        \\}
+        \\
+    );
+}
+
 const std = @import("std");
 const mem = std.mem;
 const warn = std.debug.warn;
lib/std/zig/render.zig
@@ -1489,7 +1489,7 @@ fn renderExpression(
             try renderToken(tree, ais, builtin_call.builtin_token, Space.None); // @name
 
             const src_params_trailing_comma = blk: {
-                if (builtin_call.params_len < 2) break :blk false;
+                if (builtin_call.params_len == 0) break :blk false;
                 const last_node = builtin_call.params()[builtin_call.params_len - 1];
                 const maybe_comma = tree.nextToken(last_node.lastToken());
                 break :blk tree.token_ids[maybe_comma] == .Comma;