Report type errors in list pattern matches

This commit is contained in:
Ayaz Hafiz 2022-10-31 17:03:19 -05:00
parent f9cb71fcf7
commit fbdf76e490
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
3 changed files with 70 additions and 62 deletions

View file

@ -1736,24 +1736,28 @@ fn solve(
close_pattern_matched_tag_unions(subs, real_var);
}
let ExhaustiveSummary {
if let Ok(ExhaustiveSummary {
errors,
exhaustive,
redundancies,
} = check(subs, real_var, sketched_rows, context);
}) = check(subs, real_var, sketched_rows, context)
{
// Store information about whether the "when" is exhaustive, and
// which (if any) of its branches are redundant. Codegen may use
// this for branch-fixing and redundant elimination.
if !exhaustive {
exhaustive_mark.set_non_exhaustive(subs);
}
for redundant_mark in redundancies {
redundant_mark.set_redundant(subs);
}
// Store information about whether the "when" is exhaustive, and
// which (if any) of its branches are redundant. Codegen may use
// this for branch-fixing and redundant elimination.
if !exhaustive {
exhaustive_mark.set_non_exhaustive(subs);
// Store the errors.
problems.extend(errors.into_iter().map(TypeError::Exhaustive));
} else {
// Otherwise there were type errors deeper in the pattern; we will have
// already reported them.
}
for redundant_mark in redundancies {
redundant_mark.set_redundant(subs);
}
// Store the errors.
problems.extend(errors.into_iter().map(TypeError::Exhaustive));
}
state