From a6889a4f6d2b384a447ccfcfa35badf6572228f9 Mon Sep 17 00:00:00 2001 From: Ayaz Hafiz Date: Tue, 25 Oct 2022 11:58:38 -0500 Subject: [PATCH] Coalesce annotation in typed function constraining --- crates/compiler/constrain/src/expr.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/crates/compiler/constrain/src/expr.rs b/crates/compiler/constrain/src/expr.rs index 84faf69806..1c6ac429a4 100644 --- a/crates/compiler/constrain/src/expr.rs +++ b/crates/compiler/constrain/src/expr.rs @@ -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