diff --git a/crates/dash_parser/src/expr.rs b/crates/dash_parser/src/expr.rs index d1bbe706..4e157233 100644 --- a/crates/dash_parser/src/expr.rs +++ b/crates/dash_parser/src/expr.rs @@ -15,6 +15,12 @@ impl<'a, 'interner> Parser<'a, 'interner> { self.parse_sequence() } + /// Parses an expression without the comma operator. + pub fn parse_expression_no_comma(&mut self) -> Option { + // Impl detail of the expression parser: comma has a lower precedence than yield, so start by parsing yield exprs + self.parse_yield() + } + fn parse_sequence(&mut self) -> Option { let mut expr = self.parse_yield()?; diff --git a/crates/dash_parser/src/stmt.rs b/crates/dash_parser/src/stmt.rs index bc223299..40c573ad 100644 --- a/crates/dash_parser/src/stmt.rs +++ b/crates/dash_parser/src/stmt.rs @@ -616,7 +616,7 @@ impl<'a, 'interner> Parser<'a, 'interner> { return None; } - self.parse_expression() + self.parse_expression_no_comma() } fn parse_switch(&mut self) -> Option {