Commit 28d449b38d
Changed files (2)
lib
std
lib/std/zig/parse.zig
@@ -732,7 +732,7 @@ fn parseIfStatement(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node
const block_expr = (try parseBlockExpr(arena, it, tree));
const assign_expr = if (block_expr == null)
- try expectNode(arena, it, tree, parseAdditionExpr, .{
+ try expectNode(arena, it, tree, parseAssignExpr, .{
.ExpectedBlockOrAssignment = .{ .token = it.index },
})
else
lib/std/zig/parser_test.zig
@@ -208,6 +208,16 @@ test "recovery: invalid comptime" {
});
}
+test "zig fmt: if statment" {
+ try testCanonical(
+ \\test "" {
+ \\ if (optional()) |some|
+ \\ bar = some.foo();
+ \\}
+ \\
+ );
+}
+
test "zig fmt: top-level fields" {
try testCanonical(
\\a: did_you_know,