diff options
author | Gunnar Beutner <gbeutner@serenityos.org> | 2021-06-07 22:06:02 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-07 22:10:57 +0200 |
commit | 2c10bd72f2e33c85157ddf2aff7c139f198ec2b7 (patch) | |
tree | ed0560f165037035931d93ee6be327c69df50f3d /Userland/Libraries/LibJS | |
parent | ed5777eb0a1c7598ac4cf0f39580d4861d8c1b62 (diff) | |
download | serenity-2c10bd72f2e33c85157ddf2aff7c139f198ec2b7.zip |
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.
Diffstat (limited to 'Userland/Libraries/LibJS')
-rw-r--r-- | Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp b/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp index 48a8633f9b..526b7a1b76 100644 --- a/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp +++ b/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp @@ -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 |