| ... | @@ -724,16 +724,12 @@ fn parseIfStatement(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node | ... | @@ -724,16 +724,12 @@ fn parseIfStatement(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node |
| 724 | const if_prefix = if_node.cast(Node.If).?; | 724 | const if_prefix = if_node.cast(Node.If).?; |
| 725 | | 725 | |
| 726 | const block_expr = (try parseBlockExpr(arena, it, tree)); | 726 | const block_expr = (try parseBlockExpr(arena, it, tree)); |
| 727 | const assign_expr = if (block_expr == null) blk: { | 727 | const assign_expr = if (block_expr == null) |
| 728 | break :blk (try parseAssignExpr(arena, it, tree)) orelse null; | 728 | try expectNode(arena, it, tree, parseAdditionExpr, .{ |
| 729 | } else null; | | |
| 730 | | | |
| 731 | if (block_expr == null and assign_expr == null) { | | |
| 732 | try tree.errors.push(.{ | | |
| 733 | .ExpectedBlockOrAssignment = .{ .token = it.index }, | 729 | .ExpectedBlockOrAssignment = .{ .token = it.index }, |
| 734 | }); | 730 | }) |
| 735 | return error.ParseError; | 731 | else |
| 736 | } | 732 | null; |
| 737 | | 733 | |
| 738 | const semicolon = if (assign_expr != null) eatToken(it, .Semicolon) else null; | 734 | const semicolon = if (assign_expr != null) eatToken(it, .Semicolon) else null; |
| 739 | | 735 | |
| ... | @@ -770,10 +766,9 @@ fn parseIfStatement(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node | ... | @@ -770,10 +766,9 @@ fn parseIfStatement(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node |
| 770 | try tree.errors.push(.{ | 766 | try tree.errors.push(.{ |
| 771 | .ExpectedSemiOrElse = .{ .token = it.index }, | 767 | .ExpectedSemiOrElse = .{ .token = it.index }, |
| 772 | }); | 768 | }); |
| 773 | return error.ParseError; | | |
| 774 | } | 769 | } |
| 775 | | 770 | |
| 776 | unreachable; | 771 | return if_node; |
| 777 | } | 772 | } |
| 778 | | 773 | |
| 779 | /// LabeledStatement <- BlockLabel? (Block / LoopStatement) | 774 | /// LabeledStatement <- BlockLabel? (Block / LoopStatement) |
| ... | @@ -879,7 +874,8 @@ fn parseForStatement(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node | ... | @@ -879,7 +874,8 @@ fn parseForStatement(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node |
| 879 | try tree.errors.push(.{ | 874 | try tree.errors.push(.{ |
| 880 | .ExpectedSemiOrElse = .{ .token = it.index }, | 875 | .ExpectedSemiOrElse = .{ .token = it.index }, |
| 881 | }); | 876 | }); |
| 882 | return null; | 877 | |
| | 878 | return node; |
| 883 | } | 879 | } |
| 884 | | 880 | |
| 885 | return null; | 881 | return null; |
| ... | @@ -941,7 +937,8 @@ fn parseWhileStatement(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*No | ... | @@ -941,7 +937,8 @@ fn parseWhileStatement(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*No |
| 941 | try tree.errors.push(.{ | 937 | try tree.errors.push(.{ |
| 942 | .ExpectedSemiOrElse = .{ .token = it.index }, | 938 | .ExpectedSemiOrElse = .{ .token = it.index }, |
| 943 | }); | 939 | }); |
| 944 | return null; | 940 | |
| | 941 | return node; |
| 945 | } | 942 | } |
| 946 | | 943 | |
| 947 | return null; | 944 | return null; |