| ... | ... | @@ -1637,13 +1637,17 @@ fn parseExprPrecedence(p: *Parse, min_prec: i32) Error!?Node.Index { |
| 1637 | 1637 | if (tok_tag == .keyword_catch) { |
| 1638 | 1638 | _ = try p.parsePayload(); |
| 1639 | 1639 | } |
| 1640 | | const rhs = try p.parseExprPrecedence(info.prec + 1) orelse { |
| 1641 | | try p.warn(.expected_expr); |
| 1642 | | return node; |
| 1643 | | }; |
| 1644 | 1640 | |
| 1641 | // Check for whitespace error before parsing the rhs to facilitate fuzzing. |
| 1642 | // Consider the case where there is a mismatched whitespace error but the rhs |
| 1643 | // expression triggers stack overflow when parsing is attempted. In this case |
| 1644 | // we want to return with an error rather than crashing on stack overflow. |
| 1645 | 1645 | { |
| 1646 | 1646 | const tok_len = tok_tag.lexeme().?.len; |
| 1647 | if (p.tokenStart(oper_token) + tok_len >= p.source.len) { |
| 1648 | try p.warn(.expected_expr); |
| 1649 | return node; |
| 1650 | } |
| 1647 | 1651 | const char_before = p.source[p.tokenStart(oper_token) - 1]; |
| 1648 | 1652 | const char_after = p.source[p.tokenStart(oper_token) + tok_len]; |
| 1649 | 1653 | if (tok_tag == .ampersand and char_after == '&') { |
| ... | ... | @@ -1655,6 +1659,11 @@ fn parseExprPrecedence(p: *Parse, min_prec: i32) Error!?Node.Index { |
| 1655 | 1659 | } |
| 1656 | 1660 | } |
| 1657 | 1661 | |
| 1662 | const rhs = try p.parseExprPrecedence(info.prec + 1) orelse { |
| 1663 | try p.warn(.expected_expr); |
| 1664 | return node; |
| 1665 | }; |
| 1666 | |
| 1658 | 1667 | node = try p.addNode(.{ |
| 1659 | 1668 | .tag = info.tag, |
| 1660 | 1669 | .main_token = oper_token, |