Coalesce annotation in typed function constraining

This commit is contained in:
Ayaz Hafiz 2022-10-25 11:58:38 -05:00
parent 6c4722fe1c
commit a6889a4f6d
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58

View file

@ -2530,11 +2530,9 @@ fn constrain_typed_function_arguments(
let it = arguments.iter().zip(arg_types.iter()).enumerate();
for (index, ((pattern_var, annotated_mark, loc_pattern), ann)) in it {
let pattern_var_index = constraints.push_type(Variable(*pattern_var));
let ann_index = constraints.push_type(ann.clone());
if loc_pattern.value.surely_exhaustive() {
// TODO coalesce with ann_index below
let ann_index = constraints.push_type(ann.clone());
// OPT: we don't need to perform any type-level exhaustiveness checking.
// Check instead only that the pattern unifies with the annotation type.
let pattern_expected = PExpected::ForReason(
@ -2560,8 +2558,6 @@ fn constrain_typed_function_arguments(
// this constraint must be to the def_pattern_state's constraints
def_pattern_state.vars.push(*pattern_var);
let ann_index = constraints.push_type(ann.clone());
let ann_expected =
constraints.push_expected_type(Expected::NoExpectation(ann_index));
let pattern_con = constraints.equal_types_var(
@ -2599,7 +2595,6 @@ fn constrain_typed_function_arguments(
{
// Store the actual type in a variable.
let ann_index = constraints.push_type(ann.clone());
let ann_expected =
constraints.push_expected_type(Expected::NoExpectation(ann_index));
argument_pattern_state