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:
Anonymous 2021-06-19 20:13:53 -07:00 committed by Linus Groh
commit 2822da8c8f
Notes: sideshowbarker 2024-07-18 11:38:05 +09:00
10 changed files with 121 additions and 20 deletions

View file

@ -226,11 +226,15 @@ Associativity Parser::operator_associativity(TokenType type) const
}
}
NonnullRefPtr<Program> Parser::parse_program()
NonnullRefPtr<Program> Parser::parse_program(bool starts_in_strict_mode)
{
auto rule_start = push_start();
ScopePusher scope(*this, ScopePusher::Var | ScopePusher::Let | ScopePusher::Function);
auto program = adopt_ref(*new Program({ m_filename, rule_start.position(), position() }));
if (starts_in_strict_mode) {
program->set_strict_mode();
m_state.strict_mode = true;
}
bool first = true;
while (!done()) {