mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +00:00
no manual rank hacking please
This commit is contained in:
parent
149ddf7309
commit
5372c45cdd
1 changed files with 2 additions and 22 deletions
|
@ -229,33 +229,13 @@ fn unify_structure(
|
||||||
}
|
}
|
||||||
RecursionVar { structure, .. } => match flat_type {
|
RecursionVar { structure, .. } => match flat_type {
|
||||||
FlatType::TagUnion(_, _) => {
|
FlatType::TagUnion(_, _) => {
|
||||||
let structure_rank = subs.get(*structure).rank;
|
|
||||||
let self_rank = subs.get(ctx.first).rank;
|
|
||||||
let other_rank = subs.get(ctx.second).rank;
|
|
||||||
// unify the structure with this unrecursive tag union
|
// unify the structure with this unrecursive tag union
|
||||||
let problems = unify_pool(subs, pool, ctx.first, *structure);
|
unify_pool(subs, pool, ctx.first, *structure)
|
||||||
|
|
||||||
let min_rank = structure_rank.min(self_rank).min(other_rank);
|
|
||||||
subs.set_rank(*structure, min_rank);
|
|
||||||
subs.set_rank(ctx.first, min_rank);
|
|
||||||
subs.set_rank(ctx.second, min_rank);
|
|
||||||
|
|
||||||
problems
|
|
||||||
}
|
}
|
||||||
FlatType::RecursiveTagUnion(rec, _, _) => {
|
FlatType::RecursiveTagUnion(rec, _, _) => {
|
||||||
debug_assert!(is_recursion_var(subs, *rec));
|
debug_assert!(is_recursion_var(subs, *rec));
|
||||||
let structure_rank = subs.get(*structure).rank;
|
|
||||||
let self_rank = subs.get(ctx.first).rank;
|
|
||||||
let other_rank = subs.get(ctx.second).rank;
|
|
||||||
// unify the structure with this recursive tag union
|
// unify the structure with this recursive tag union
|
||||||
let problems = unify_pool(subs, pool, ctx.first, *structure);
|
unify_pool(subs, pool, ctx.first, *structure)
|
||||||
|
|
||||||
let min_rank = structure_rank.min(self_rank).min(other_rank);
|
|
||||||
subs.set_rank(*structure, min_rank);
|
|
||||||
subs.set_rank(ctx.first, min_rank);
|
|
||||||
subs.set_rank(ctx.second, min_rank);
|
|
||||||
|
|
||||||
problems
|
|
||||||
}
|
}
|
||||||
_ => todo!("rec structure {:?}", &flat_type),
|
_ => todo!("rec structure {:?}", &flat_type),
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue