mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:27:43 +00:00
LibJS: Restore the environment if an exception is thrown in 'with' block
This commit is contained in:
parent
4175be6960
commit
db0a48d34c
2 changed files with 24 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue