Skip to content

Commit

Permalink
safely error within eval if compilation error
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwparas committed Oct 31, 2024
1 parent 8b1449d commit 9b7a863
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion crates/steel-core/src/steel_vm/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4596,7 +4596,10 @@ fn eval_program(program: crate::compiler::program::Executable, ctx: &mut VmCore)
for (instr, span) in instructions.into_iter().zip(spans) {
new_spans.extend_from_slice(&span);
bytecode.extend_from_slice(&instr);
bytecode.last_mut().unwrap().op_code = OpCode::POPSINGLE;
bytecode
.last_mut()
.ok_or_else(throw!(Generic => "Compilation error: empty expression"))?
.op_code = OpCode::POPSINGLE;
}
bytecode.last_mut().unwrap().op_code = OpCode::POPPURE;
let function_id = crate::compiler::code_gen::fresh_function_id();
Expand Down

0 comments on commit 9b7a863

Please sign in to comment.