mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-05 16:14:38 +00:00
LibJS: Make sure scope expressions yield the correct value
When evaluated as an expression "{ 3 }" should yield 3. This updates
the bytecode interpreter to make it so.
This commit is contained in:
committed by
Andreas Kling
parent
ed5777eb0a
commit
2c10bd72f2
@@ -21,10 +21,11 @@ Optional<Bytecode::Register> ASTNode::generate_bytecode(Bytecode::Generator&) co
|
||||
Optional<Bytecode::Register> ScopeNode::generate_bytecode(Bytecode::Generator& generator) const
|
||||
{
|
||||
generator.emit<Bytecode::Op::EnterScope>(*this);
|
||||
Optional<Bytecode::Register> last_value_reg;
|
||||
for (auto& child : children()) {
|
||||
[[maybe_unused]] auto reg = child.generate_bytecode(generator);
|
||||
last_value_reg = child.generate_bytecode(generator);
|
||||
}
|
||||
return {};
|
||||
return last_value_reg;
|
||||
}
|
||||
|
||||
Optional<Bytecode::Register> EmptyStatement::generate_bytecode(Bytecode::Generator&) const
|
||||
|
||||
Reference in New Issue
Block a user