Skip to content

Commit

Permalink
Allow let name in for-in loop in non-strict mode
Browse files Browse the repository at this point in the history
  • Loading branch information
HalidOdat committed May 8, 2023
1 parent 7605453 commit 410d990
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion boa_parser/src/parser/statement/iteration/for_statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,21 @@ where
.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)
.parse(cursor, interner)?
.into(),
Expand Down

0 comments on commit 410d990

Please sign in to comment.