fix(paresr): parse [+In] in template (#266)

relates #255
This commit is contained in:
Boshen 2023-04-06 21:37:34 +08:00 committed by GitHub
parent 6360bdad31
commit 398dbfd2a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View file

@ -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();
}
}

View file

@ -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 {