mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-04 01:12:56 +00:00
LibJS: Evaluate for statements in their own scope if necessary
We now evaluate for loops in their own scope if their init statement is a lexical declaration. Evaluating for loops in their own scope allow us to obtain expected behaviour, which means for example, that the block-scoped variables declared in a for statement will be limited to the scope of the for loop's body and statement and not to that of the current scope (i.e the one where the for statement was made)
This commit is contained in:
parent
0659d07241
commit
644b4f4201
Notes:
sideshowbarker
2024-07-19 08:18:43 +09:00
Author: https://github.com/0xtechnobabble
Commit: 644b4f4201
Pull-request: https://github.com/SerenityOS/serenity/pull/1445
Reviewed-by: https://github.com/awesomekling
Reviewed-by: https://github.com/deoxxa
4 changed files with 17 additions and 3 deletions
|
@ -68,8 +68,8 @@ void Interpreter::enter_scope(const ScopeNode& scope_node, Vector<Argument> argu
|
|||
|
||||
void Interpreter::exit_scope(const ScopeNode& scope_node)
|
||||
{
|
||||
ASSERT(&m_scope_stack.last().scope_node == &scope_node);
|
||||
m_scope_stack.take_last();
|
||||
while (&m_scope_stack.last().scope_node != &scope_node)
|
||||
m_scope_stack.take_last();
|
||||
}
|
||||
|
||||
void Interpreter::do_return()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue