| ... | @@ -1437,7 +1437,8 @@ const Parser = struct { | ... | @@ -1437,7 +1437,8 @@ const Parser = struct { |
| 1437 | } | 1437 | } |
| 1438 | const rhs = try p.parseExprPrecedence(info.prec + 1); | 1438 | const rhs = try p.parseExprPrecedence(info.prec + 1); |
| 1439 | if (rhs == 0) { | 1439 | if (rhs == 0) { |
| 1440 | return p.fail(.invalid_token); | 1440 | try p.warn(.expected_expr); |
| | 1441 | return node; |
| 1441 | } | 1442 | } |
| 1442 | | 1443 | |
| 1443 | node = try p.addNode(.{ | 1444 | node = try p.addNode(.{ |
| ... | @@ -1916,7 +1917,7 @@ const Parser = struct { | ... | @@ -1916,7 +1917,7 @@ const Parser = struct { |
| 1916 | | 1917 | |
| 1917 | /// IfExpr <- IfPrefix Expr (KEYWORD_else Payload? Expr)? | 1918 | /// IfExpr <- IfPrefix Expr (KEYWORD_else Payload? Expr)? |
| 1918 | fn parseIfExpr(p: *Parser) !Node.Index { | 1919 | fn parseIfExpr(p: *Parser) !Node.Index { |
| 1919 | return p.parseIf(parseExpr); | 1920 | return p.parseIf(expectExpr); |
| 1920 | } | 1921 | } |
| 1921 | | 1922 | |
| 1922 | /// Block <- LBRACE Statement* RBRACE | 1923 | /// Block <- LBRACE Statement* RBRACE |
| ... | @@ -2384,7 +2385,7 @@ const Parser = struct { | ... | @@ -2384,7 +2385,7 @@ const Parser = struct { |
| 2384 | | 2385 | |
| 2385 | .builtin => return p.parseBuiltinCall(), | 2386 | .builtin => return p.parseBuiltinCall(), |
| 2386 | .keyword_fn => return p.parseFnProto(), | 2387 | .keyword_fn => return p.parseFnProto(), |
| 2387 | .keyword_if => return p.parseIf(parseTypeExpr), | 2388 | .keyword_if => return p.parseIf(expectTypeExpr), |
| 2388 | .keyword_switch => return p.expectSwitchExpr(), | 2389 | .keyword_switch => return p.expectSwitchExpr(), |
| 2389 | | 2390 | |
| 2390 | .keyword_extern, | 2391 | .keyword_extern, |
| ... | @@ -3577,7 +3578,7 @@ const Parser = struct { | ... | @@ -3577,7 +3578,7 @@ const Parser = struct { |
| 3577 | _ = try p.parsePtrPayload(); | 3578 | _ = try p.parsePtrPayload(); |
| 3578 | | 3579 | |
| 3579 | const then_expr = try bodyParseFn(p); | 3580 | const then_expr = try bodyParseFn(p); |
| 3580 | if (then_expr == 0) return p.fail(.invalid_token); | 3581 | assert(then_expr != 0); |
| 3581 | | 3582 | |
| 3582 | _ = p.eatToken(.keyword_else) orelse return p.addNode(.{ | 3583 | _ = p.eatToken(.keyword_else) orelse return p.addNode(.{ |
| 3583 | .tag = .if_simple, | 3584 | .tag = .if_simple, |
| ... | @@ -3589,7 +3590,7 @@ const Parser = struct { | ... | @@ -3589,7 +3590,7 @@ const Parser = struct { |
| 3589 | }); | 3590 | }); |
| 3590 | _ = try p.parsePayload(); | 3591 | _ = try p.parsePayload(); |
| 3591 | const else_expr = try bodyParseFn(p); | 3592 | const else_expr = try bodyParseFn(p); |
| 3592 | if (else_expr == 0) return p.fail(.invalid_token); | 3593 | assert(then_expr != 0); |
| 3593 | | 3594 | |
| 3594 | return p.addNode(.{ | 3595 | return p.addNode(.{ |
| 3595 | .tag = .@"if", | 3596 | .tag = .@"if", |