Allow uninhabited type extension to happen on either unification side

This commit is contained in:
Ayaz Hafiz 2022-09-20 14:20:47 -05:00
parent 49ba8b92b4
commit f96c825aa4
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
2 changed files with 22 additions and 23 deletions

View file

@ -1356,19 +1356,8 @@ fn solve(
);
let snapshot = subs.snapshot();
let unify_cond_and_patterns_outcome = {
// When unifying the cond type with what the branches expect, we'll want the
// branches to gain constructors that are uninabited; that way, we can permit
// unification of things like
// [Ok Str] ~ [Ok Str, Result []]
// which we want here, because `Result []` need not be matched - it is
// impossible to construct!
//
// The order of variables is important here - to do such a unification, the
// unifier expects the branch variable on the left, and the condition variable
// (containing uninhabited variants to grow by) on the right.
unify(&mut UEnv::new(subs), branches_var, real_var, Mode::EQ)
};
let unify_cond_and_patterns_outcome =
unify(&mut UEnv::new(subs), branches_var, real_var, Mode::EQ);
let should_check_exhaustiveness;
match unify_cond_and_patterns_outcome {