diff --git a/compiler/mono/src/ir.rs b/compiler/mono/src/ir.rs index fcd5d2ab0f..660ae0b0cb 100644 --- a/compiler/mono/src/ir.rs +++ b/compiler/mono/src/ir.rs @@ -5867,7 +5867,9 @@ pub fn from_can<'a>( Err(_) => todo!(), }; - if let Pattern::Identifier(_symbol) = mono_pattern { + if matches!(mono_pattern, Pattern::Identifier(_symbol)) + || matches!(def.loc_expr.value, roc_can::expr::Expr::Var(..)) + { internal_error!("Identifier patterns should be handled in a higher code pass!") } @@ -5895,23 +5897,19 @@ pub fn from_can<'a>( ); } - if let roc_can::expr::Expr::Var(outer_symbol) = def.loc_expr.value { - store_pattern(env, procs, layout_cache, &mono_pattern, outer_symbol, stmt) - } else { - let outer_symbol = env.unique_symbol(); - stmt = store_pattern(env, procs, layout_cache, &mono_pattern, outer_symbol, stmt); + let outer_symbol = env.unique_symbol(); + stmt = store_pattern(env, procs, layout_cache, &mono_pattern, outer_symbol, stmt); - // convert the def body, store in outer_symbol - with_hole( - env, - def.loc_expr.value, - def.expr_var, - procs, - layout_cache, - outer_symbol, - env.arena.alloc(stmt), - ) - } + // convert the def body, store in outer_symbol + with_hole( + env, + def.loc_expr.value, + def.expr_var, + procs, + layout_cache, + outer_symbol, + env.arena.alloc(stmt), + ) } _ => {