Generalize recursion variables properly

Closes #2379
Closes #2481
This commit is contained in:
ayazhafiz 2022-02-17 23:04:33 -05:00
parent 9226bafdfa
commit 909fae5b6c
2 changed files with 64 additions and 1 deletions

View file

@ -895,8 +895,11 @@ fn type_to_variable<'a>(
let tag_union_var = register(subs, rank, pools, content);
subs.set_content(
register_with_known_var(
subs,
*rec_var,
rank,
pools,
Content::RecursionVar {
opt_name: None,
structure: tag_union_var,
@ -2030,3 +2033,22 @@ fn register(subs: &mut Subs, rank: Rank, pools: &mut Pools, content: Content) ->
var
}
fn register_with_known_var(
subs: &mut Subs,
var: Variable,
rank: Rank,
pools: &mut Pools,
content: Content,
) {
let descriptor = Descriptor {
content,
rank,
mark: Mark::NONE,
copy: OptVariable::NONE,
};
subs.set(var, descriptor);
pools.get_mut(rank).push(var);
}