authorgravatar for vincent@rischmann.frVincent Rischmann <vincent@rischmann.fr> 2021-03-06 19:37:33+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-03-06 17:39:54-08:00
log272ae0ca0dff89689ad9715a4d8fa98ed86440b9
tree3c1ab7b65156f417b88f85768b54ef6ec70811fa
parent34cb5934ddd7c79fb96ffed87768764247740260

fix parsing of assignment with 'inline for' and 'inline while'


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

lib/std/zig/parse.zig+1-1
......@@ -1981,7 +1981,7 @@ const Parser = struct {
19811981 }
19821982 },
19831983 .keyword_inline => {
1984 p.tok_i += 2;
1984 p.tok_i += 1;
19851985 switch (p.token_tags[p.tok_i]) {
19861986 .keyword_for => return p.parseForExpr(),
19871987 .keyword_while => return p.parseWhileExpr(),
lib/std/zig/parser_test.zig+12
......@@ -4297,6 +4297,18 @@ test "zig fmt: respect extra newline between switch items" {
42974297 );
42984298}
42994299
4300test "zig fmt: assignment with inline for and inline while" {
4301 try testCanonical(
4302 \\const tmp = inline for (items) |item| {};
4303 \\
4304 );
4305
4306 try testCanonical(
4307 \\const tmp2 = inline while (true) {};
4308 \\
4309 );
4310}
4311
43004312test "zig fmt: insert trailing comma if there are comments between switch values" {
43014313 try testTransform(
43024314 \\const a = switch (b) {