zig fmt: function with labeled block as return type

This commit is contained in:
Andrew Kelley 2021-02-24 16:42:46 -07:00
parent c79ee1fc8d
commit 9ada7638a5
2 changed files with 15 additions and 0 deletions

View File

@ -2656,6 +2656,10 @@ const Parser = struct {
p.tok_i += 2;
return p.parseWhileTypeExpr();
},
.l_brace => {
p.tok_i += 2;
return p.parseBlock();
},
else => return p.addNode(.{
.tag = .identifier,
.main_token = p.nextToken(),

View File

@ -4179,6 +4179,17 @@ test "zig fmt: proper indent line comment after multi-line single expr while loo
);
}
test "zig fmt: function with labeled block as return type" {
try testCanonical(
\\fn foo() t: {
\\ break :t bar;
\\} {
\\ baz();
\\}
\\
);
}
test "zig fmt: line comment after multiline single expr if statement with multiline string" {
try testCanonical(
\\test {