authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-02-24 21:50:20-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-02-24 21:50:57-07:00
log9b8a94265ab7313f07b300ddc349a60c85d556d1
tree80ca48193b327cc749d404292878186399182627
parent5f35dc0c0d0530d5a1d028c56a763def3d1fd250

zig fmt: fix extern function with missing param name

Regressed in d7049fc8e0709619b8aa6766b37abeae946703b2.

2 files changed, 15 insertions(+), 2 deletions(-)

lib/std/zig/parser_test.zig+11
......@@ -4190,6 +4190,17 @@ test "zig fmt: function with labeled block as return type" {
41904190 );
41914191}
41924192
4193test "zig fmt: extern function with missing param name" {
4194 try testCanonical(
4195 \\extern fn a(
4196 \\ *b,
4197 \\ c: *d,
4198 \\) e;
4199 \\extern fn f(*g, h: *i) j;
4200 \\
4201 );
4202}
4203
41934204test "zig fmt: line comment after multiline single expr if statement with multiline string" {
41944205 try testCanonical(
41954206 \\test {
lib/std/zig/render.zig+4-2
......@@ -1449,9 +1449,11 @@ fn renderFnProto(gpa: *Allocator, ais: *Ais, tree: ast.Tree, fn_proto: ast.full.
14491449 continue;
14501450 },
14511451 .r_paren => break,
1452 else => unreachable,
1452 else => {}, // Parameter type without a name.
14531453 }
1454 if (token_tags[last_param_token] == .identifier) {
1454 if (token_tags[last_param_token] == .identifier and
1455 token_tags[last_param_token + 1] == .colon)
1456 {
14551457 try renderToken(ais, tree, last_param_token, .none); // name
14561458 last_param_token += 1;
14571459 try renderToken(ais, tree, last_param_token, .space); // :