mirror of
https://github.com/roc-lang/roc.git
synced 2025-07-23 14:35:12 +00:00
Support unification of extension types with uninhabited branches
This commit is contained in:
parent
8a42d60ca2
commit
be853b65c5
4 changed files with 83 additions and 9 deletions
|
@ -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,
|
||||
|
|
|
@ -4275,7 +4275,7 @@ mod solve_expr {
|
|||
x
|
||||
"#
|
||||
),
|
||||
"[Empty, Foo Bar I64]",
|
||||
"[Empty, Foo [Bar] I64]",
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -7788,7 +7788,7 @@ mod solve_expr {
|
|||
Ok s -> s
|
||||
"#
|
||||
),
|
||||
"",
|
||||
"Str",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue