diff options
author | Luke Wilde <lukew@serenityos.org> | 2022-03-15 01:44:32 +0000 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2022-03-15 11:57:51 +0330 |
commit | 515f3e0b8596fda1fe7d39cccded71cbfbaa1c4b (patch) | |
tree | 1847d033d5bd3335db11de1e9046451013a3364f /Userland/Libraries/LibJS | |
parent | 1fc6bbcdc333e13b72a94cce53411d19dc71ca50 (diff) | |
download | serenity-515f3e0b8596fda1fe7d39cccded71cbfbaa1c4b.zip |
LibJS/Bytecode: End for's variable scope after update block generation
The update block can generate bytecode that refers to the lexical
environment, so we have to end the scope after it has been generated.
Previously the Jump to the update block would terminate the block,
causing us to leave the lexical environment just before jumping to the
update block.
Diffstat (limited to 'Userland/Libraries/LibJS')
-rw-r--r-- | Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp b/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp index cd2ac0f7a4..03c4fc0900 100644 --- a/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp +++ b/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp @@ -782,9 +782,6 @@ Bytecode::CodeGenerationErrorOr<void> ForStatement::generate_bytecode(Bytecode:: generator.end_breakable_scope(); generator.end_continuable_scope(); - if (has_lexical_environment) - generator.end_variable_scope(); - if (!generator.is_current_block_terminated()) { if (m_update) { generator.emit<Bytecode::Op::Jump>().set_targets( @@ -803,6 +800,9 @@ Bytecode::CodeGenerationErrorOr<void> ForStatement::generate_bytecode(Bytecode:: generator.emit<Bytecode::Op::Load>(result_reg); } + if (has_lexical_environment) + generator.end_variable_scope(); + return {}; } |