From 40b6e86a999ce80b9f71c7a88df6186400f151ac Mon Sep 17 00:00:00 2001 From: Lachlan Easton Date: Thu, 10 Sep 2020 20:32:40 +1000 Subject: [PATCH] zig fmt: fix #6171 --- lib/std/zig/parser_test.zig | 18 ++++++++++++++++++ lib/std/zig/render.zig | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/std/zig/parser_test.zig b/lib/std/zig/parser_test.zig index d6dd9c1a73f54fdab91e0145400887138948494a..f3cfe811a4b94255f3e39a7d519ea140c0805701 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 78f8ddb022b83f0eb5ac14c44e9cc112f7cb07d0..fbf2139b428a4044388c8e28f5d3cc6139d45be1 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; -- 2.54.0