Also fix the jump if its the last one

Signed-off-by: Marcel Müller <neikos@neikos.email>
This commit is contained in:
Marcel Müller 2026-03-09 13:04:16 +01:00
parent ff308649b9
commit ae379df9db
7 changed files with 185 additions and 2 deletions

View file

@ -147,7 +147,7 @@ fn emit_ast_expr(
*jump = new_jump as isize;
} else {
panic!("Got an else without a previous if?");
};
}
if let Some(expression) = expression {
let emit_slot = machine.reserve_slot();
@ -167,6 +167,15 @@ fn emit_ast_expr(
}
}
if let Some(previous_jump) = previous_jump.take() {
let new_jump = eval.len() - previous_jump - 1;
let Instruction::JumpIfNotTrue { jump, .. } = &mut eval[previous_jump] else {
panic!("Jump slot had something that is not a jump?!");
};
*jump = new_jump as isize;
}
if let Some(ws) = previous_post_whitespace_content {
eval.push(Instruction::AppendContent {
content: ws.source().clone(),