Skip to content

Commit

Permalink
disassociate new exprs in function call arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
y21 committed Dec 27, 2023
1 parent cf2954d commit 54678f2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/dash_middle/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ impl<T> fmt::Debug for SharedOnce<T> {
}
}

#[derive(Default)]
#[derive(Debug, Default)]
pub struct LevelStack(SmallVec<[u8; 4]>);

impl LevelStack {
Expand Down
4 changes: 4 additions & 0 deletions crates/dash_parser/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,9 @@ impl<'a, 'interner> Parser<'a, 'interner> {
TokenType::LeftParen => {
let mut arguments = Vec::new();

// Disassociate any new expressions in arguments such that `new x(() => x());`
// is parsed as having the `new` operator only apply to the `x` identifier.
self.new_level_stack.add_level();
// TODO: refactor to `parse_expr_list`
while !self.expect_token_type_and_skip(&[TokenType::RightParen], false) {
self.expect_token_type_and_skip(&[TokenType::Comma], false);
Expand All @@ -316,6 +319,7 @@ impl<'a, 'interner> Parser<'a, 'interner> {
arguments.push(CallArgumentKind::Normal(self.parse_yield()?));
}
}
self.new_level_stack.pop_level().expect("Missing `new` level stack");

// End of function call.
let level = self.new_level_stack.cur_level().expect("Missing `new` level stack");
Expand Down

0 comments on commit 54678f2

Please sign in to comment.