authorgravatar for lachlan@lakebythewoods.xyzLachlan Easton <lachlan@lakebythewoods.xyz> 2020-09-10 20:32:40+10:00
committergravatar for lachlan@lakebythewoods.xyzLachlan Easton <lachlan@lakebythewoods.xyz> 2020-09-18 20:34:00+10:00
log40b6e86a999ce80b9f71c7a88df6186400f151ac
treea66bf1128d0bb465d35b042c4b6d5707d9fa2ecc
parentc06674e701fdd74165778dd46b72cc469ba29140

zig fmt: fix #6171


2 files changed, 19 insertions(+), 1 deletions(-)

lib/std/zig/parser_test.zig+18
......@@ -3583,6 +3583,24 @@ test "zig fmt: use of comments and Multiline string literals may force the param
35833583 );
35843584}
35853585
3586test "zig fmt: single argument trailing commas in @builtins()" {
3587 try testCanonical(
3588 \\pub fn foo(qzz: []u8) i1 {
3589 \\ @panic(
3590 \\ foo,
3591 \\ );
3592 \\ panic(
3593 \\ foo,
3594 \\ );
3595 \\ @panic(
3596 \\ foo,
3597 \\ bar,
3598 \\ );
3599 \\}
3600 \\
3601 );
3602}
3603
35863604const std = @import("std");
35873605const mem = std.mem;
35883606const warn = std.debug.warn;
lib/std/zig/render.zig+1-1
......@@ -1489,7 +1489,7 @@ fn renderExpression(
14891489 try renderToken(tree, ais, builtin_call.builtin_token, Space.None); // @name
14901490
14911491 const src_params_trailing_comma = blk: {
1492 if (builtin_call.params_len < 2) break :blk false;
1492 if (builtin_call.params_len == 0) break :blk false;
14931493 const last_node = builtin_call.params()[builtin_call.params_len - 1];
14941494 const maybe_comma = tree.nextToken(last_node.lastToken());
14951495 break :blk tree.token_ids[maybe_comma] == .Comma;