1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:57:45 +00:00

LibJS: Actually leave the current function scope on "return"

We now unwind until the nearest function-level scope on the scope stack
when executing a return statement.
This commit is contained in:
Andreas Kling 2020-03-23 19:19:03 +01:00
parent df524203b2
commit 494df52961
3 changed files with 13 additions and 6 deletions

View file

@ -81,7 +81,7 @@ Value CallExpression::execute(Interpreter& interpreter) const
Value ReturnStatement::execute(Interpreter& interpreter) const
{
auto value = argument() ? argument()->execute(interpreter) : js_undefined();
interpreter.do_return();
interpreter.unwind(ScopeType::Function);
return value;
}