mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 22:09:09 +00:00
FlexAble must always constrain a Flex
This commit is contained in:
parent
85b3110bea
commit
5a5fc0162d
1 changed files with 6 additions and 7 deletions
|
@ -1813,11 +1813,12 @@ fn unify_flex(
|
||||||
other: &Content,
|
other: &Content,
|
||||||
) -> Outcome {
|
) -> Outcome {
|
||||||
match other {
|
match other {
|
||||||
FlexVar(None) => {
|
FlexVar(other_opt_name) => {
|
||||||
// If both are flex, and only left has a name, keep the name around.
|
// Prefer using right's name.
|
||||||
|
let opt_name = opt_name.or(*other_opt_name);
|
||||||
match opt_able_bound {
|
match opt_able_bound {
|
||||||
Some(ability) => merge(subs, ctx, FlexAbleVar(*opt_name, ability)),
|
Some(ability) => merge(subs, ctx, FlexAbleVar(opt_name, ability)),
|
||||||
None => merge(subs, ctx, FlexVar(*opt_name)),
|
None => merge(subs, ctx, FlexVar(opt_name)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1849,8 +1850,7 @@ fn unify_flex(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FlexVar(Some(_))
|
RigidVar(_)
|
||||||
| RigidVar(_)
|
|
||||||
| RigidAbleVar(_, _)
|
| RigidAbleVar(_, _)
|
||||||
| RecursionVar { .. }
|
| RecursionVar { .. }
|
||||||
| Structure(_)
|
| Structure(_)
|
||||||
|
@ -1858,7 +1858,6 @@ fn unify_flex(
|
||||||
| RangedNumber(..) => {
|
| RangedNumber(..) => {
|
||||||
// TODO special-case boolean here
|
// TODO special-case boolean here
|
||||||
// In all other cases, if left is flex, defer to right.
|
// In all other cases, if left is flex, defer to right.
|
||||||
// (This includes using right's name if both are flex and named.)
|
|
||||||
merge(subs, ctx, *other)
|
merge(subs, ctx, *other)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue