de-alias when diffing with a non-alias

When one of the types in a comparison is an alias, elm does not de-alias it.
That is really annoying if e.g. the alias is of a record and you used an invalid field: the field suggestion error does not kick in
This commit is contained in:
Folkert 2020-04-11 23:51:51 +02:00
parent 2811f978a4
commit d15bd07bf4
5 changed files with 33 additions and 12 deletions

View file

@ -524,6 +524,9 @@ pub fn constrain_expr(
constraints.push(ast_con);
for (index, when_branch) in branches.iter().enumerate() {
let pattern_region =
Region::across_all(when_branch.patterns.iter().map(|v| &v.region));
let branch_con = constrain_when_branch(
env,
when_branch.value.region,
@ -533,12 +536,14 @@ pub fn constrain_expr(
index: Index::zero_based(index),
},
cond_type.clone(),
Region::across_all(when_branch.patterns.iter().map(|v| &v.region)),
pattern_region,
),
FromAnnotation(
name.clone(),
*arity,
TypedWhenBranch(Index::zero_based(index)),
TypedWhenBranch {
index: Index::zero_based(index),
},
typ.clone(),
),
);
@ -552,6 +557,8 @@ pub fn constrain_expr(
let mut branch_cons = Vec::with_capacity(branches.len());
for (index, when_branch) in branches.iter().enumerate() {
let pattern_region =
Region::across_all(when_branch.patterns.iter().map(|v| &v.region));
let branch_con = constrain_when_branch(
env,
region,
@ -561,7 +568,7 @@ pub fn constrain_expr(
index: Index::zero_based(index),
},
cond_type.clone(),
Region::across_all(when_branch.patterns.iter().map(|v| &v.region)),
pattern_region,
),
ForReason(
Reason::WhenBranch {