Simplify pattern constraint generation

At the time we introduced presence constraints for tag unions, I added a
"destruct_position" variable so that we didn't change the typechecking
semantics for everything all at once, and because I wasn't totally sure
what I was doing was correct. But now we're more confident in this
approach, and every pattern is by definition a destructuring, so there
is no need for this flag.

Also should fix some potential bugs we didn't notice before with presence
constraints in closure variables, though I can't find a good test to
reproduce this, since closure variables are hidden from the user.
This commit is contained in:
ayazhafiz 2022-02-24 01:08:18 -05:00
parent 7e70f2e9ad
commit f8c7349193
2 changed files with 39 additions and 90 deletions

View file

@ -80,7 +80,6 @@ fn constrain_untyped_args(
loc_pattern.region,
pattern_expected,
&mut pattern_state,
true,
);
vars.push(*pattern_var);
@ -1039,7 +1038,6 @@ fn constrain_when_branch(
loc_pattern.region,
pattern_expected.clone(),
&mut state,
true,
);
}
@ -1143,7 +1141,6 @@ fn constrain_def_pattern(env: &Env, loc_pattern: &Loc<Pattern>, expr_type: Type)
loc_pattern.region,
pattern_expected,
&mut state,
true,
);
state
@ -1264,7 +1261,6 @@ fn constrain_def(env: &Env, def: &Def, body_con: Constraint) -> Constraint {
loc_pattern.region,
pattern_expected,
&mut state,
false,
);
}
@ -1632,7 +1628,6 @@ pub fn rec_defs_help(
loc_pattern.region,
pattern_expected,
&mut state,
false,
);
}