Skip to content

Commit

Permalink
fix(paresr): parse [+In] in template (#266)
Browse files Browse the repository at this point in the history
relates #255
  • Loading branch information
Boshen authored Apr 6, 2023
1 parent 6360bda commit 398dbfd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions crates/oxc_parser/src/js/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,9 @@ impl<'a> Parser<'a> {
}
Kind::TemplateHead => {
quasis.push(self.parse_template_element(tagged));
expressions.push(self.parse_expression()?);
// TemplateHead Expression[+In, ?Yield, ?Await]
let expr = self.with_context(Context::In, Self::parse_expression)?;
expressions.push(expr);
self.re_lex_template_substitution_tail();
loop {
match self.cur_kind() {
Expand All @@ -362,7 +364,9 @@ impl<'a> Parser<'a> {
quasis.push(self.parse_template_element(tagged));
}
_ => {
expressions.push(self.parse_expression()?);
// TemplateMiddle Expression[+In, ?Yield, ?Await]
let expr = self.with_context(Context::In, Self::parse_expression)?;
expressions.push(expr);
self.re_lex_template_substitution_tail();
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/oxc_parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ mod test {
"null?async():null",
"switch(null){case async():}",
"for(new null(null in null);;);",
"for(`${null in null}`;;);",
];

for source in pass {
Expand Down

0 comments on commit 398dbfd

Please sign in to comment.