Browse Source

Allow `let` name in for-in loop in non-strict mode (#2915)

pull/2918/head
Haled Odat 1 year ago committed by GitHub
parent
commit
128c13752a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      boa_parser/src/parser/statement/iteration/for_statement.rs

16
boa_parser/src/parser/statement/iteration/for_statement.rs

@ -116,7 +116,21 @@ where
.into(), .into(),
) )
} }
TokenKind::Keyword((Keyword::Let | Keyword::Const, _)) => Some( TokenKind::Keyword((Keyword::Let, _)) => Some('exit: {
if !cursor.strict() {
if let Some(token) = cursor.peek(1, interner)? {
if token.kind() == &TokenKind::Keyword((Keyword::In, false)) {
cursor.advance(interner);
break 'exit boa_ast::Expression::Identifier(Sym::LET.into()).into();
}
}
}
LexicalDeclaration::new(false, self.allow_yield, self.allow_await, true)
.parse(cursor, interner)?
.into()
}),
TokenKind::Keyword((Keyword::Const, _)) => Some(
LexicalDeclaration::new(false, self.allow_yield, self.allow_await, true) LexicalDeclaration::new(false, self.allow_yield, self.allow_await, true)
.parse(cursor, interner)? .parse(cursor, interner)?
.into(), .into(),

Loading…
Cancel
Save