Skip to content

Commit e056c14

Browse files
committed
bugfix conditional scoping
1 parent 3d1c833 commit e056c14

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

crates/lean_compiler/src/b_compile_intermediate.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,6 @@ fn compile_lines(
272272
else_branch,
273273
line_number,
274274
} => {
275-
compiler.stack_frame_layout.scopes.push(ScopeLayout::default());
276-
277275
let if_id = compiler.if_counter;
278276
compiler.if_counter += 1;
279277

@@ -348,10 +346,14 @@ fn compile_lines(
348346

349347
let saved_stack_pos = compiler.stack_pos;
350348

349+
compiler.stack_frame_layout.scopes.push(ScopeLayout::default());
351350
let then_instructions = compile_lines(function_name, then_branch, compiler, Some(end_label.clone()))?;
352351

353352
let then_stack_pos = compiler.stack_pos;
354353
compiler.stack_pos = saved_stack_pos;
354+
compiler.stack_frame_layout.scopes.pop();
355+
compiler.stack_frame_layout.scopes.push(ScopeLayout::default());
356+
355357
let else_instructions = compile_lines(function_name, else_branch, compiler, Some(end_label.clone()))?;
356358

357359
compiler.bytecode.insert(if_label, then_instructions);

0 commit comments

Comments
 (0)