mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:48:14 +00:00
LibJS: Correct behaviour of direct vs. indirect eval
eval only has direct access to the local scope when accessed through the name eval. This includes locals named eval, because of course it does.
This commit is contained in:
parent
5d24b5f4be
commit
2822da8c8f
10 changed files with 121 additions and 20 deletions
|
@ -220,6 +220,11 @@ Value CallExpression::execute(Interpreter& interpreter, GlobalObject& global_obj
|
|||
}
|
||||
}
|
||||
|
||||
if (!is<NewExpression>(*this) && is<Identifier>(*m_callee) && static_cast<Identifier const&>(*m_callee).string() == vm.names.eval.as_string() && &callee.as_function() == global_object.eval_function()) {
|
||||
auto script_value = arguments.size() == 0 ? js_undefined() : arguments[0];
|
||||
return perform_eval(script_value, global_object, vm.in_strict_mode() ? CallerMode::Strict : CallerMode::NonStrict, EvalMode::Direct);
|
||||
}
|
||||
|
||||
vm.call_frame().current_node = interpreter.current_node();
|
||||
Object* new_object = nullptr;
|
||||
Value result;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue