Support unification of extension types with uninhabited branches

This commit is contained in:
Ayaz Hafiz 2022-09-19 10:32:39 -05:00
parent 8a42d60ca2
commit be853b65c5
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
4 changed files with 83 additions and 9 deletions

View file

@ -1356,10 +1356,19 @@ fn solve(
);
let snapshot = subs.snapshot();
let outcome = unify(&mut UEnv::new(subs), real_var, branches_var, Mode::EQ);
let unify_cond_and_patterns_outcome = {
// When unifying the cond type with what the branches expect, allow 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!
let mode = Mode::EQ_WITH_EXTENSION_BY_UNINHABITED_TYPES;
unify(&mut UEnv::new(subs), branches_var, real_var, mode)
};
let should_check_exhaustiveness;
match outcome {
match unify_cond_and_patterns_outcome {
Success {
vars,
must_implement_ability,