diff --git a/crates/oxc_parser/src/js/expression.rs b/crates/oxc_parser/src/js/expression.rs index 81bd23666..72e37eea3 100644 --- a/crates/oxc_parser/src/js/expression.rs +++ b/crates/oxc_parser/src/js/expression.rs @@ -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() { @@ -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(); } } diff --git a/crates/oxc_parser/src/lib.rs b/crates/oxc_parser/src/lib.rs index b8cc2dc2e..71f3c94aa 100644 --- a/crates/oxc_parser/src/lib.rs +++ b/crates/oxc_parser/src/lib.rs @@ -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 {