mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +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:
committed by
Andreas Kling
parent
63a0ebcc90
commit
c7a99aafac
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user