rust catch_unwind as a safeguard

This commit is contained in:
2025-12-01 15:35:44 -07:00
parent 997dd50585
commit abaefa294b
2 changed files with 84 additions and 66 deletions

View File

@@ -797,7 +797,11 @@ impl<'a, W: std::io::Write> Compiler<'a, W> {
self.write_output(format!("j {end_label}"))?;
self.write_output(format!("{else_label}:"))?;
match expr.else_branch.unwrap().node {
match expr
.else_branch
.ok_or(Error::Unknown("Missing else branch. This should not happen and indicates a Compiler Error. Please report to the author.".into(), None))?
.node
{
Expression::Block(block) => self.expression_block(block.node, scope)?,
Expression::If(if_expr) => self.expression_if(if_expr.node, scope)?,
_ => unreachable!("Parser ensures else branch is Block or If"),