diff options
author | davidot <david.tuin@gmail.com> | 2021-09-08 20:46:11 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-09-08 20:37:39 +0100 |
commit | db0a48d34c3dfa689a2e284cc282a49785647cd0 (patch) | |
tree | 0a3583f7a45b9cc23f386d5ef3681b0c311d0f0c /Userland/Libraries/LibJS/AST.cpp | |
parent | 4175be69600b6c427aea161f8d3aa5033ab024cb (diff) | |
download | serenity-db0a48d34c3dfa689a2e284cc282a49785647cd0.zip |
LibJS: Restore the environment if an exception is thrown in 'with' block
Diffstat (limited to 'Userland/Libraries/LibJS/AST.cpp')
-rw-r--r-- | Userland/Libraries/LibJS/AST.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Userland/Libraries/LibJS/AST.cpp b/Userland/Libraries/LibJS/AST.cpp index 80dd4f6448..658d5b6081 100644 --- a/Userland/Libraries/LibJS/AST.cpp +++ b/Userland/Libraries/LibJS/AST.cpp @@ -379,12 +379,13 @@ Value WithStatement::execute(Interpreter& interpreter, GlobalObject& global_obje // 6. Let C be the result of evaluating Statement. auto result = interpreter.execute_statement(global_object, m_body).value_or(js_undefined()); - if (interpreter.exception()) - return {}; // 7. Set the running execution context's LexicalEnvironment to oldEnv. interpreter.vm().running_execution_context().lexical_environment = old_environment; + if (interpreter.exception()) + return {}; + // 8. Return Completion(UpdateEmpty(C, undefined)). return result; } |