mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
Fix deriving of hash ability for recursive tag unions
This commit is contained in:
parent
02b02901bc
commit
2517695ce4
4 changed files with 25 additions and 8 deletions
|
@ -140,7 +140,8 @@ impl FlatHash {
|
||||||
},
|
},
|
||||||
Content::RangedNumber(_) => Err(Underivable),
|
Content::RangedNumber(_) => Err(Underivable),
|
||||||
//
|
//
|
||||||
Content::RecursionVar { .. } => Err(Underivable),
|
Content::RecursionVar { structure, .. } => Self::from_var(subs, structure),
|
||||||
|
//
|
||||||
Content::Error => Err(Underivable),
|
Content::Error => Err(Underivable),
|
||||||
Content::FlexVar(_)
|
Content::FlexVar(_)
|
||||||
| Content::RigidVar(_)
|
| Content::RigidVar(_)
|
||||||
|
|
|
@ -655,7 +655,7 @@ fn make_specialization_decision<P: Phase>(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Structure(_) | Alias(_, _, _, _) => {
|
Structure(_) | Alias(_, _, _, _) | RecursionVar { .. } => {
|
||||||
let builtin = match ability_member.try_into() {
|
let builtin = match ability_member.try_into() {
|
||||||
Ok(builtin) => builtin,
|
Ok(builtin) => builtin,
|
||||||
Err(_) => return SpecializeDecision::Drop,
|
Err(_) => return SpecializeDecision::Drop,
|
||||||
|
@ -691,7 +691,6 @@ fn make_specialization_decision<P: Phase>(
|
||||||
| RigidAbleVar(..)
|
| RigidAbleVar(..)
|
||||||
| FlexVar(..)
|
| FlexVar(..)
|
||||||
| RigidVar(..)
|
| RigidVar(..)
|
||||||
| RecursionVar { .. }
|
|
||||||
| LambdaSet(..)
|
| LambdaSet(..)
|
||||||
| RangedNumber(..) => {
|
| RangedNumber(..) => {
|
||||||
internal_error!("unexpected")
|
internal_error!("unexpected")
|
||||||
|
|
|
@ -1568,7 +1568,6 @@ mod hash {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore = "TODO"]
|
|
||||||
fn hash_recursive_tag_union() {
|
fn hash_recursive_tag_union() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
&format!(
|
&format!(
|
||||||
|
@ -1591,7 +1590,11 @@ mod hash {
|
||||||
),
|
),
|
||||||
TEST_HASHER,
|
TEST_HASHER,
|
||||||
),
|
),
|
||||||
RocList::from_slice(&[0]),
|
RocList::from_slice(&[
|
||||||
|
0, 0, 1, // Cons 1
|
||||||
|
0, 0, 2, // Cons 2
|
||||||
|
1, 0, // Nil
|
||||||
|
]),
|
||||||
RocList<u8>
|
RocList<u8>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2937,7 +2937,6 @@ fn unify_flex_able<M: MetaCollector>(
|
||||||
}
|
}
|
||||||
|
|
||||||
RigidVar(_) => mismatch!("FlexAble can never unify with non-able Rigid"),
|
RigidVar(_) => mismatch!("FlexAble can never unify with non-able Rigid"),
|
||||||
RecursionVar { .. } => mismatch!("FlexAble with RecursionVar"),
|
|
||||||
LambdaSet(..) => mismatch!("FlexAble with LambdaSet"),
|
LambdaSet(..) => mismatch!("FlexAble with LambdaSet"),
|
||||||
|
|
||||||
Alias(name, _args, _real_var, AliasKind::Opaque) => {
|
Alias(name, _args, _real_var, AliasKind::Opaque) => {
|
||||||
|
@ -2952,7 +2951,10 @@ fn unify_flex_able<M: MetaCollector>(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Structure(_) | Alias(_, _, _, AliasKind::Structural) | RangedNumber(..) => {
|
RecursionVar { .. }
|
||||||
|
| Structure(_)
|
||||||
|
| Alias(_, _, _, AliasKind::Structural)
|
||||||
|
| RangedNumber(..) => {
|
||||||
// Structural type wins.
|
// Structural type wins.
|
||||||
merge_flex_able_with_concrete(
|
merge_flex_able_with_concrete(
|
||||||
env,
|
env,
|
||||||
|
@ -3035,10 +3037,22 @@ fn unify_recursion<M: MetaCollector>(
|
||||||
mismatch!("RecursionVar {:?} with rigid {:?}", ctx.first, &other)
|
mismatch!("RecursionVar {:?} with rigid {:?}", ctx.first, &other)
|
||||||
}
|
}
|
||||||
|
|
||||||
FlexAbleVar(..) | RigidAbleVar(..) => {
|
RigidAbleVar(..) => {
|
||||||
mismatch!("RecursionVar {:?} with able var {:?}", ctx.first, &other)
|
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(
|
FlexVar(_) => merge(
|
||||||
env,
|
env,
|
||||||
ctx,
|
ctx,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue