1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:38:12 +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

@ -3492,7 +3492,7 @@ NonnullRefPtr<Statement> Parser::parse_for_in_of_statement(NonnullRefPtr<ASTNode
has_annexB_for_in_init_extension = true;
}
}
} else if (!lhs->is_identifier() && !is<MemberExpression>(*lhs)) {
} else if (!lhs->is_identifier() && !is<MemberExpression>(*lhs) && !is<CallExpression>(*lhs)) {
bool valid = false;
if (is<ObjectExpression>(*lhs) || is<ArrayExpression>(*lhs)) {
auto synthesized_binding_pattern = synthesize_binding_pattern(static_cast<Expression const&>(*lhs));