fix problem with recursive definition constraint gen

This commit is contained in:
Folkert 2020-11-10 19:37:33 +01:00
parent b54c1a2194
commit 3aa6455795
7 changed files with 137 additions and 103 deletions

View file

@ -2545,32 +2545,30 @@ pub fn rec_defs_help(
applied_usage_constraint,
def.loc_expr.region,
&def.loc_expr.value,
Expected::NoExpectation(expr_type.clone()),
annotation_expected.clone(),
);
// ensure expected type unifies with annotated type
rigid_info.constraints.push(Eq(
let storage_con = Eq(
expr_type,
annotation_expected.clone(),
annotation_expected,
Category::Storage,
def.loc_expr.region,
));
);
// TODO investigate if this let can be safely removed
let def_con = Let(Box::new(LetConstraint {
rigid_vars: Vec::new(),
flex_vars: Vec::new(), // empty because Roc function defs have no args
def_types: SendMap::default(), // empty because Roc function defs have no args
defs_constraint: True, // I think this is correct, once again because there are no args
defs_constraint: storage_con,
ret_constraint: expr_con,
}));
rigid_info.vars.extend(&new_rigids);
// because of how in Roc headers point to variables, we must include the pattern var here
rigid_info.vars.extend(pattern_state.vars);
rigid_info.constraints.push(Let(Box::new(LetConstraint {
rigid_vars: new_rigids,
flex_vars: Vec::new(), // no flex vars introduced
flex_vars: pattern_state.vars,
def_types: SendMap::default(), // no headers introduced (at this level)
defs_constraint: def_con,
ret_constraint: True,