zig fmt while-else with no blocks

master
Josh Wolfe 2018-04-10 22:44:55 -04:00
parent f6c77746d6
commit 405a2390f0
1 changed files with 7 additions and 1 deletions

View File

@ -3845,6 +3845,7 @@ pub const Parser = struct {
ast.Node.Id.Block, ast.Node.Id.If,
ast.Node.Id.For, ast.Node.Id.While,
ast.Node.Id.Switch => {
try stream.print(" ");
try stack.append(RenderState { .Expression = else_node.body });
},
else => {
@ -4805,6 +4806,11 @@ test "zig fmt: while" {
\\ unreachable;
\\ };
\\
\\ const res = while (0 < 10)
\\ break 7
\\ else
\\ unreachable;
\\
\\ var a: error!u8 = 0;
\\ while (a) |v| {
\\ a = error.Err;