Commit 483933d88d

Matthew Borkowski <matthew.h.borkowski@gmail.com>
2021-06-12 00:23:38
parse.zig: make parseForTypeExpr accept only a TypeExpr as body
1 parent 3692fb0
Changed files (2)
lib/std/zig/parse.zig
@@ -2616,7 +2616,7 @@ const Parser = struct {
         const found_payload = try p.parsePtrIndexPayload();
         if (found_payload == 0) try p.warn(.expected_loop_payload);
 
-        const then_expr = try p.expectExpr();
+        const then_expr = try p.expectTypeExpr();
         const else_token = p.eatToken(.keyword_else) orelse {
             return p.addNode(.{
                 .tag = .for_simple,
lib/std/zig/parser_test.zig
@@ -5154,7 +5154,7 @@ test "recovery: missing for payload" {
     try testError(
         \\comptime {
         \\    const a = for(a) {};
-        \\    const a: for(a) {};
+        \\    const a: for(a) blk: {};
         \\    for(a) {}
         \\}
     , &[_]Error{