Merge pull request #4209 from roc-lang/impl-tag-discriminant

Derive `Hash` implementations for tag unions
This commit is contained in:
Ayaz 2022-10-10 22:23:05 -05:00 committed by GitHub
commit 83b64c4fb3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 844 additions and 106 deletions

View file

@ -2948,7 +2948,6 @@ fn unify_flex_able<M: MetaCollector>(
}
RigidVar(_) => mismatch!("FlexAble can never unify with non-able Rigid"),
RecursionVar { .. } => mismatch!("FlexAble with RecursionVar"),
LambdaSet(..) => mismatch!("FlexAble with LambdaSet"),
Alias(name, _args, _real_var, AliasKind::Opaque) => {
@ -2963,7 +2962,10 @@ fn unify_flex_able<M: MetaCollector>(
)
}
Structure(_) | Alias(_, _, _, AliasKind::Structural) | RangedNumber(..) => {
RecursionVar { .. }
| Structure(_)
| Alias(_, _, _, AliasKind::Structural)
| RangedNumber(..) => {
// Structural type wins.
merge_flex_able_with_concrete(
env,
@ -3046,10 +3048,22 @@ fn unify_recursion<M: MetaCollector>(
mismatch!("RecursionVar {:?} with rigid {:?}", ctx.first, &other)
}
FlexAbleVar(..) | RigidAbleVar(..) => {
RigidAbleVar(..) => {
mismatch!("RecursionVar {:?} with able var {:?}", ctx.first, &other)
}
FlexAbleVar(_, ability) => merge_flex_able_with_concrete(
env,
ctx,
ctx.second,
*ability,
RecursionVar {
structure,
opt_name: *opt_name,
},
Obligated::Adhoc(ctx.first),
),
FlexVar(_) => merge(
env,
ctx,