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
commit 494df52961
Notes: sideshowbarker 2024-07-19 08:10:08 +09:00
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;
}