mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 06:58:11 +00:00
LibJS: Use ScopePusher to correctly push the scope in for statements
We were previously pushing a scope but forgetting to actually set it as the current scope.
This commit is contained in:
parent
63a0ebcc90
commit
c7a99aafac
1 changed files with 3 additions and 9 deletions
|
@ -2687,19 +2687,13 @@ NonnullRefPtr<Statement> Parser::parse_for_statement()
|
|||
|
||||
consume(TokenType::ParenOpen);
|
||||
|
||||
bool in_scope = false;
|
||||
ScopeGuard guard([&]() {
|
||||
if (in_scope)
|
||||
m_state.let_scopes.take_last();
|
||||
});
|
||||
Optional<ScopePusher> scope_pusher;
|
||||
|
||||
RefPtr<ASTNode> init;
|
||||
if (!match(TokenType::Semicolon)) {
|
||||
if (match_variable_declaration()) {
|
||||
if (!match(TokenType::Var)) {
|
||||
m_state.let_scopes.append(NonnullRefPtrVector<VariableDeclaration>());
|
||||
in_scope = true;
|
||||
}
|
||||
if (!match(TokenType::Var))
|
||||
scope_pusher.emplace(*this, ScopePusher::Let, Scope::Block);
|
||||
init = parse_variable_declaration(true);
|
||||
if (match_for_in_of())
|
||||
return parse_for_in_of_statement(*init);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue