specialize substituted variables

This commit is contained in:
Folkert 2020-11-10 13:38:13 +01:00
parent b62de8fc3c
commit a48f244cc7

View file

@ -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) => {