mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Make sure to apply "is-open" constraints at the very end of pattern constraining
Closes #3298
This commit is contained in:
parent
613606a67d
commit
13b0ce7ca0
5 changed files with 85 additions and 62 deletions
|
@ -838,26 +838,7 @@ fn unify_structure<M: MetaCollector>(
|
|||
match other {
|
||||
FlexVar(_) => {
|
||||
// If the other is flex, Structure wins!
|
||||
let outcome = merge(subs, ctx, Structure(*flat_type));
|
||||
|
||||
// And if we see a flex variable on the right hand side of a presence
|
||||
// constraint, we know we need to open up the structure we're trying to unify with.
|
||||
match (ctx.mode.is_present(), flat_type) {
|
||||
(true, FlatType::TagUnion(tags, _ext)) => {
|
||||
let new_ext = subs.fresh_unnamed_flex_var();
|
||||
let mut new_desc = ctx.first_desc;
|
||||
new_desc.content = Structure(FlatType::TagUnion(*tags, new_ext));
|
||||
subs.set(ctx.first, new_desc);
|
||||
}
|
||||
(true, FlatType::FunctionOrTagUnion(tn, sym, _ext)) => {
|
||||
let new_ext = subs.fresh_unnamed_flex_var();
|
||||
let mut new_desc = ctx.first_desc;
|
||||
new_desc.content = Structure(FlatType::FunctionOrTagUnion(*tn, *sym, new_ext));
|
||||
subs.set(ctx.first, new_desc);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
outcome
|
||||
merge(subs, ctx, Structure(*flat_type))
|
||||
}
|
||||
FlexAbleVar(_, ability) => {
|
||||
// Structure wins
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue