LibJS/Rust: Push LeaveLexicalEnvironment boundary in for-of loops
When a for-of loop creates a per-iteration lexical environment for let/const declarations, push a LeaveLexicalEnvironment boundary so that continue/break/return properly restores the lexical environment. The for-in codegen already did this but for-of was missing it.
This commit is contained in:
parent
f0c34d54a1
commit
7602e030e7
1 changed files with 4 additions and 0 deletions
|
|
@ -6747,6 +6747,9 @@ fn generate_for_of_statement_inner(
|
|||
|
||||
// Body
|
||||
generator.begin_continuable_scope(update_block, labels, completion.clone());
|
||||
if needs_lexical_env {
|
||||
generator.start_boundary(BlockBoundaryType::LeaveLexicalEnvironment);
|
||||
}
|
||||
|
||||
if !generator.is_current_block_terminated() {
|
||||
generate_with_completion(body, generator, &completion, preferred_dst);
|
||||
|
|
@ -6754,6 +6757,7 @@ fn generate_for_of_statement_inner(
|
|||
|
||||
// Restore lexical env before continuing
|
||||
if needs_lexical_env {
|
||||
generator.end_boundary(BlockBoundaryType::LeaveLexicalEnvironment);
|
||||
generator.lexical_environment_register_stack.pop();
|
||||
}
|
||||
generator.end_continuable_scope();
|
||||
|
|
|
|||
Loading…
Reference in a new issue