Construct exhaustiveness branches with condition, not branch, variable

Previously we would construct the shapes of unions used in the pattern
tree for exhaustiveness checking using the type of the branch patterns,
rather than the type of the condition variable. Clearly we want to
always use the condition variable, otherwise some branches will be
seen as exhaustive, when they are not!

To do this, we now index into the condition variable while refying the
patterns to build the tree for exhaustiveness checking.

Closes #4068
This commit is contained in:
Ayaz Hafiz 2022-09-19 13:31:21 -05:00
parent 0f0e414272
commit 1799d6ed0e
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
4 changed files with 203 additions and 57 deletions

View file

@ -1480,7 +1480,7 @@ fn solve(
errors,
exhaustive,
redundancies,
} = check(subs, 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