Skip to content

Commit

Permalink
correctly parse variable declarations with multiple definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
y21 committed Dec 28, 2023
1 parent 23a5583 commit 97bf6cc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions crates/dash_parser/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Expr> {
// 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<Expr> {
let mut expr = self.parse_yield()?;

Expand Down
2 changes: 1 addition & 1 deletion crates/dash_parser/src/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SwitchStatement> {
Expand Down

0 comments on commit 97bf6cc

Please sign in to comment.