diff --git a/compiler/gen/src/llvm/build.rs b/compiler/gen/src/llvm/build.rs index ecb40b74ea..a2e2c8f3c6 100644 --- a/compiler/gen/src/llvm/build.rs +++ b/compiler/gen/src/llvm/build.rs @@ -1494,9 +1494,9 @@ pub fn build_exp_stmt<'a, 'ctx, 'env>( call, layout, pass, - fail: roc_mono::ir::Stmt::Unreachable, + fail: roc_mono::ir::Stmt::Rethrow, } => { - // when the fail case is just Unreachable, there is no cleanup work to do + // when the fail case is just Rethrow, there is no cleanup work to do // so we can just treat this invoke as a normal call let stmt = roc_mono::ir::Stmt::Let(*symbol, Expr::Call(call.clone()), layout.clone(), pass); @@ -1561,7 +1561,7 @@ pub fn build_exp_stmt<'a, 'ctx, 'env>( } }, - Unreachable => { + Rethrow => { cxa_rethrow_exception(env); // used in exception handling diff --git a/compiler/mono/src/borrow.rs b/compiler/mono/src/borrow.rs index 019a2249c2..8fe05e3e7e 100644 --- a/compiler/mono/src/borrow.rs +++ b/compiler/mono/src/borrow.rs @@ -170,7 +170,7 @@ impl<'a> ParamMap<'a> { } Inc(_, _) | Dec(_, _) => unreachable!("these have not been introduced yet"), - Ret(_) | Unreachable | Jump(_, _) | RuntimeError(_) => { + Ret(_) | Rethrow | Jump(_, _) | RuntimeError(_) => { // these are terminal, do nothing } } @@ -515,7 +515,7 @@ impl<'a> BorrowInfState<'a> { } Inc(_, _) | Dec(_, _) => unreachable!("these have not been introduced yet"), - Ret(_) | RuntimeError(_) | Unreachable => { + Ret(_) | RuntimeError(_) | Rethrow => { // these are terminal, do nothing } } diff --git a/compiler/mono/src/inc_dec.rs b/compiler/mono/src/inc_dec.rs index 219dba7607..27503a35e1 100644 --- a/compiler/mono/src/inc_dec.rs +++ b/compiler/mono/src/inc_dec.rs @@ -50,7 +50,7 @@ pub fn occuring_variables(stmt: &Stmt<'_>) -> (MutSet, MutSet) { result.insert(*symbol); } - Unreachable => {} + Rethrow => {} Inc(symbol, cont) | Dec(symbol, cont) => { result.insert(*symbol); @@ -792,7 +792,7 @@ impl<'a> Context<'a> { } } - Unreachable => (stmt, MutSet::default()), + Rethrow => (stmt, MutSet::default()), Jump(j, xs) => { let empty = MutSet::default(); @@ -953,7 +953,7 @@ pub fn collect_stmt( vars } - Unreachable => vars, + Rethrow => vars, RuntimeError(_) => vars, } diff --git a/compiler/mono/src/ir.rs b/compiler/mono/src/ir.rs index 8ad8820390..f011c2857e 100644 --- a/compiler/mono/src/ir.rs +++ b/compiler/mono/src/ir.rs @@ -762,7 +762,7 @@ pub enum Stmt<'a> { ret_layout: Layout<'a>, }, Ret(Symbol), - Unreachable, + Rethrow, Inc(Symbol, &'a Stmt<'a>), Dec(Symbol, &'a Stmt<'a>), Join { @@ -911,11 +911,6 @@ pub enum CallType<'a> { }, } -// x = f a b c; S -// -// -// invoke x = f a b c in S else Unreachable - #[derive(Clone, Debug, PartialEq)] pub enum Expr<'a> { Literal(Literal<'a>), @@ -1133,7 +1128,7 @@ impl<'a> Stmt<'a> { symbol, call, pass, - fail: Stmt::Unreachable, + fail: Stmt::Rethrow, .. } => alloc .text("let ") @@ -1166,7 +1161,7 @@ impl<'a> Stmt<'a> { .append(symbol_to_doc(alloc, *symbol)) .append(";"), - Unreachable => alloc.text("unreachable;"), + Rethrow => alloc.text("unreachable;"), Switch { cond_symbol, @@ -4572,7 +4567,7 @@ fn substitute_in_stmt_help<'a>( } } - Unreachable => None, + Rethrow => None, RuntimeError(_) => None, } @@ -5293,7 +5288,7 @@ fn build_call<'a>( hole: &'a Stmt<'a>, ) -> Stmt<'a> { if can_throw_exception(&call) { - let fail = env.arena.alloc(Stmt::Unreachable); + let fail = env.arena.alloc(Stmt::Rethrow); Stmt::Invoke { symbol: assigned, call, diff --git a/compiler/mono/src/tail_recursion.rs b/compiler/mono/src/tail_recursion.rs index 4998c5fd84..87aa45038c 100644 --- a/compiler/mono/src/tail_recursion.rs +++ b/compiler/mono/src/tail_recursion.rs @@ -102,7 +102,7 @@ fn insert_jumps<'a>( pass: Stmt::Ret(rsym), .. } if needle == *fsym && symbol == rsym => { - debug_assert_eq!(fail, &&Stmt::Unreachable); + debug_assert_eq!(fail, &&Stmt::Rethrow); // replace the call and return with a jump @@ -237,7 +237,7 @@ fn insert_jumps<'a>( None => None, }, - Unreachable => None, + Rethrow => None, Ret(_) => None, Jump(_, _) => None, RuntimeError(_) => None,