change the span of the if jump to the else

This commit is contained in:
Devyn Cairns 2024-06-27 19:58:17 -07:00
parent b02d6e44fc
commit a6c2d39879
No known key found for this signature in database

View File

@ -885,8 +885,10 @@ fn compile_if(
)?;
// Add a jump over the false case
let index_of_jump =
builder.push(Instruction::Jump { index: usize::MAX }.into_spanned(call.head))?;
let index_of_jump = builder.push(
Instruction::Jump { index: usize::MAX }
.into_spanned(else_arg.map(|e| e.span).unwrap_or(call.head)),
)?;
// Change the branch-if target to after the jump
builder.set_branch_target(index_of_branch_if, index_of_jump + 1)?;