FlexAble must always constrain a Flex

This commit is contained in:
Ayaz Hafiz 2022-05-06 17:40:04 -04:00 committed by ayazhafiz
parent 85b3110bea
commit 5a5fc0162d

View file

@ -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)
} }