diff options
| author | Lachlan Easton <lachlan@lakebythewoods.xyz> | 2020-09-10 20:32:40 +1000 |
|---|---|---|
| committer | Lachlan Easton <lachlan@lakebythewoods.xyz> | 2020-09-18 20:34:00 +1000 |
| commit | 40b6e86a999ce80b9f71c7a88df6186400f151ac (patch) | |
| tree | a66bf1128d0bb465d35b042c4b6d5707d9fa2ecc /lib | |
| parent | c06674e701fdd74165778dd46b72cc469ba29140 (diff) | |
| download | zig-40b6e86a999ce80b9f71c7a88df6186400f151ac.tar.gz zig-40b6e86a999ce80b9f71c7a88df6186400f151ac.zip | |
zig fmt: fix #6171
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/std/zig/parser_test.zig | 18 | ||||
| -rw-r--r-- | lib/std/zig/render.zig | 2 |
2 files changed, 19 insertions, 1 deletions
diff --git a/lib/std/zig/parser_test.zig b/lib/std/zig/parser_test.zig index d6dd9c1a73..f3cfe811a4 100644 --- a/lib/std/zig/parser_test.zig +++ b/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; diff --git a/lib/std/zig/render.zig b/lib/std/zig/render.zig index 78f8ddb022..fbf2139b42 100644 --- a/lib/std/zig/render.zig +++ b/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; |
