no more rigid mistakes?

This commit is contained in:
Folkert 2020-11-12 15:31:25 +01:00
parent 7a719172bc
commit 75d18eb8ba

View file

@ -1220,11 +1220,17 @@ fn constrain_def(env: &Env, def: &Def, body_con: Constraint) -> Constraint {
ret_constraint, ret_constraint,
})), })),
// "the closure's type is equal to expected type" // "the closure's type is equal to expected type"
Eq(fn_type.clone(), expected, Category::Lambda, region), Eq(fn_type.clone(), expected.clone(), Category::Lambda, region),
// "fn_var is equal to the closure's type" - fn_var is used in code gen // "fn_var is equal to the closure's type" - fn_var is used in code gen
Eq( Eq(
Type::Variable(*fn_var), Type::Variable(*fn_var),
NoExpectation(fn_type), NoExpectation(Type::Variable(expr_var)),
Category::Storage(std::file!(), std::line!()),
region,
),
Eq(
Type::Variable(expr_var),
expected,
Category::Storage(std::file!(), std::line!()), Category::Storage(std::file!(), std::line!()),
region, region,
), ),
@ -1378,6 +1384,8 @@ pub fn rec_defs_help(
let mut def_pattern_state = constrain_def_pattern(env, &def.loc_pattern, expr_type.clone()); let mut def_pattern_state = constrain_def_pattern(env, &def.loc_pattern, expr_type.clone());
def_pattern_state.vars.push(expr_var);
let mut new_rigids = Vec::new(); let mut new_rigids = Vec::new();
match &def.annotation { match &def.annotation {
None => { None => {
@ -1388,8 +1396,6 @@ pub fn rec_defs_help(
NoExpectation(expr_type), NoExpectation(expr_type),
); );
def_pattern_state.vars.push(expr_var);
// TODO investigate if this let can be safely removed // TODO investigate if this let can be safely removed
let def_con = Let(Box::new(LetConstraint { let def_con = Let(Box::new(LetConstraint {
rigid_vars: Vec::new(), rigid_vars: Vec::new(),
@ -1571,7 +1577,7 @@ pub fn rec_defs_help(
defs_constraint: And(state.constraints), defs_constraint: And(state.constraints),
ret_constraint: expr_con, ret_constraint: expr_con,
})), })),
Eq(fn_type.clone(), expected, Category::Lambda, region), Eq(fn_type.clone(), expected.clone(), Category::Lambda, region),
// "fn_var is equal to the closure's type" - fn_var is used in code gen // "fn_var is equal to the closure's type" - fn_var is used in code gen
Eq( Eq(
Type::Variable(*fn_var), Type::Variable(*fn_var),
@ -1579,6 +1585,12 @@ pub fn rec_defs_help(
Category::Storage(std::file!(), std::line!()), Category::Storage(std::file!(), std::line!()),
region, region,
), ),
Eq(
Type::Variable(expr_var),
expected,
Category::Storage(std::file!(), std::line!()),
region,
),
closure_constraint, closure_constraint,
]), ]),
); );