Fix failing reporting tests

This commit is contained in:
Ayaz Hafiz 2022-04-21 09:07:43 -04:00 committed by ayazhafiz
parent aa50b141f7
commit c01baa9168
3 changed files with 81 additions and 18 deletions

View file

@ -606,6 +606,15 @@ pub fn constrain_expr(
)
};
let branches_region = {
debug_assert!(!branches.is_empty());
Region::span_across(
&loc_cond.region,
// &branches.first().unwrap().region(),
&branches.last().unwrap().region(),
)
};
let branch_expr_reason =
|expected: &Expected<Type>, index, branch_region| match expected {
FromAnnotation(name, arity, ann_source, _typ) => {
@ -669,6 +678,17 @@ pub fn constrain_expr(
)
};
let expected_pattern = |sub_pattern| {
PExpected::ForReason(
PReason::WhenMatch {
index: HumanIndex::zero_based(index),
sub_pattern,
},
cond_type.clone(),
pattern_region,
)
};
let (new_pattern_vars, new_pattern_headers, pattern_con, branch_con) =
constrain_when_branch_help(
constraints,