1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:37:34 +00:00

LibJS: Allow CallExpression as left hand side of for-of/for-in loops

Although this will fail with a ReferenceError it should pass the parser
and only fail if actually assigned to.
This commit is contained in:
davidot 2022-02-17 01:23:10 +01:00 committed by Linus Groh
parent ce057115fc
commit 65bebb5241
4 changed files with 63 additions and 10 deletions

View file

@ -865,7 +865,7 @@ struct ForInOfHeadState {
VERIFY(declaration.declarations().first().target().has<NonnullRefPtr<Identifier>>());
lhs_reference = TRY(declaration.declarations().first().target().get<NonnullRefPtr<Identifier>>()->to_reference(interpreter, global_object));
} else {
VERIFY(is<Identifier>(*expression_lhs) || is<MemberExpression>(*expression_lhs));
VERIFY(is<Identifier>(*expression_lhs) || is<MemberExpression>(*expression_lhs) || is<CallExpression>(*expression_lhs));
auto& expression = static_cast<Expression const&>(*expression_lhs);
lhs_reference = TRY(expression.to_reference(interpreter, global_object));
}