Improve error reporting for patterns not matching opaques

This commit is contained in:
ayazhafiz 2022-02-24 23:37:33 -05:00
parent 4e27cdd21d
commit 07b1829732
7 changed files with 26 additions and 23 deletions

View file

@ -653,7 +653,7 @@ fn solve(
}
}
}
Present(typ, PresenceConstraint::IncludesTag(tag_name, tys)) => {
Present(typ, PresenceConstraint::IncludesTag(tag_name, tys, region, pattern_category)) => {
let actual = type_to_var(subs, rank, pools, cached_aliases, typ);
let tag_ty = Type::TagUnion(
vec![(tag_name.clone(), tys.clone())],
@ -667,15 +667,14 @@ fn solve(
state
}
Failure(vars, actual_type, expected_type) => {
Failure(vars, actual_type, expected_to_include_type) => {
introduce(subs, rank, pools, &vars);
// TODO: do we need a better error type here?
let problem = TypeError::BadExpr(
Region::zero(),
Category::When,
actual_type,
Expected::NoExpectation(expected_type),
let problem = TypeError::BadPattern(
*region,
pattern_category.clone(),
expected_to_include_type,
PExpected::NoExpectation(actual_type),
);
problems.push(problem);