diff --git a/compiler/mono/src/ir.rs b/compiler/mono/src/ir.rs index ec9aaf3547..34f56cbecf 100644 --- a/compiler/mono/src/ir.rs +++ b/compiler/mono/src/ir.rs @@ -14,7 +14,7 @@ use roc_types::subs::{Content, FlatType, Subs, Variable}; use std::collections::HashMap; use ven_pretty::{BoxAllocator, DocAllocator, DocBuilder}; -pub const PRETTY_PRINT_IR_SYMBOLS: bool = false; +pub const PRETTY_PRINT_IR_SYMBOLS: bool = true; #[derive(Clone, Debug, PartialEq)] pub enum MonoProblem { @@ -2173,6 +2173,17 @@ pub fn with_hole<'a>( if let roc_can::expr::Expr::Var(original) = def.loc_expr.value { substitute_in_exprs(env.arena, &mut stmt, symbol, original); + // if the substituted variable is a function, make sure we specialize it + stmt = reuse_function_symbol( + env, + procs, + layout_cache, + Some(def.expr_var), + original, + stmt, + original, + ); + stmt } else { with_hole( @@ -3576,6 +3587,17 @@ pub fn from_can<'a>( // a variable is aliased substitute_in_exprs(env.arena, &mut rest, *symbol, original); + // if the substituted variable is a function, make sure we specialize it + rest = reuse_function_symbol( + env, + procs, + layout_cache, + Some(def.expr_var), + original, + rest, + original, + ); + return rest; } roc_can::expr::Expr::LetNonRec(nested_def, nested_cont, nested_annotation) => {