mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:18:12 +00:00
LibJS: Don't assume that for-in/of target is a variable on LHS::Assign
e.g. `for ([foo.bar] in ...)` is actually a binding pattern.
This commit is contained in:
parent
56c0fdc1c4
commit
7ea095feb0
1 changed files with 6 additions and 1 deletions
|
@ -1910,7 +1910,12 @@ static Bytecode::CodeGenerationErrorOr<void> for_in_of_body_evaluation(Bytecode:
|
|||
VERIFY(declaration.declarations().size() == 1);
|
||||
TRY(assign_accumulator_to_variable_declarator(generator, declaration.declarations().first(), declaration));
|
||||
} else {
|
||||
TRY(generator.emit_store_to_reference(*lhs.get<NonnullRefPtr<ASTNode>>()));
|
||||
if (auto ptr = lhs.get_pointer<NonnullRefPtr<ASTNode>>()) {
|
||||
TRY(generator.emit_store_to_reference(**ptr));
|
||||
} else {
|
||||
auto& binding_pattern = lhs.get<NonnullRefPtr<BindingPattern>>();
|
||||
TRY(generate_binding_pattern_bytecode(generator, *binding_pattern, Bytecode::Op::SetVariable::InitializationMode::Set, Bytecode::Register::accumulator()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue