mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 13:59:08 +00:00
fix recursive layout issue
This commit is contained in:
parent
66a6080f25
commit
3a97ccd8ac
4 changed files with 8 additions and 10 deletions
|
@ -724,7 +724,7 @@ fn modify_refcount_layout_build_function<'a, 'ctx, 'env>(
|
||||||
|
|
||||||
Layout::RecursivePointer => match when_recursive {
|
Layout::RecursivePointer => match when_recursive {
|
||||||
WhenRecursive::Unreachable => {
|
WhenRecursive::Unreachable => {
|
||||||
unreachable!("recursion pointers should never be hashed directly")
|
unreachable!("recursion pointers cannot be in/decremented directly")
|
||||||
}
|
}
|
||||||
WhenRecursive::Loop(union_layout) => {
|
WhenRecursive::Loop(union_layout) => {
|
||||||
let layout = Layout::Union(*union_layout);
|
let layout = Layout::Union(*union_layout);
|
||||||
|
|
|
@ -1113,7 +1113,6 @@ fn layout_from_flat_type<'a>(
|
||||||
// That means none of the optimizations for enums or single tag tag unions apply
|
// That means none of the optimizations for enums or single tag tag unions apply
|
||||||
|
|
||||||
let rec_var = subs.get_root_key_without_compacting(rec_var);
|
let rec_var = subs.get_root_key_without_compacting(rec_var);
|
||||||
env.insert_seen(rec_var);
|
|
||||||
let mut tag_layouts = Vec::with_capacity_in(tags.len(), arena);
|
let mut tag_layouts = Vec::with_capacity_in(tags.len(), arena);
|
||||||
|
|
||||||
// VERY IMPORTANT: sort the tags
|
// VERY IMPORTANT: sort the tags
|
||||||
|
@ -1131,6 +1130,7 @@ fn layout_from_flat_type<'a>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
env.insert_seen(rec_var);
|
||||||
for (index, (_name, variables)) in tags_vec.into_iter().enumerate() {
|
for (index, (_name, variables)) in tags_vec.into_iter().enumerate() {
|
||||||
if matches!(nullable, Some(i) if i == index as i64) {
|
if matches!(nullable, Some(i) if i == index as i64) {
|
||||||
// don't add the
|
// don't add the
|
||||||
|
@ -1163,6 +1163,7 @@ fn layout_from_flat_type<'a>(
|
||||||
|
|
||||||
tag_layouts.push(tag_layout.into_bump_slice());
|
tag_layouts.push(tag_layout.into_bump_slice());
|
||||||
}
|
}
|
||||||
|
env.remove_seen(rec_var);
|
||||||
|
|
||||||
let union_layout = if let Some(tag_id) = nullable {
|
let union_layout = if let Some(tag_id) = nullable {
|
||||||
match tag_layouts.into_bump_slice() {
|
match tag_layouts.into_bump_slice() {
|
||||||
|
@ -1186,8 +1187,6 @@ fn layout_from_flat_type<'a>(
|
||||||
UnionLayout::Recursive(tag_layouts.into_bump_slice())
|
UnionLayout::Recursive(tag_layouts.into_bump_slice())
|
||||||
};
|
};
|
||||||
|
|
||||||
env.remove_seen(rec_var);
|
|
||||||
|
|
||||||
Ok(Layout::Union(union_layout))
|
Ok(Layout::Union(union_layout))
|
||||||
}
|
}
|
||||||
EmptyTagUnion => {
|
EmptyTagUnion => {
|
||||||
|
@ -1422,10 +1421,6 @@ pub fn union_sorted_tags_help<'a>(
|
||||||
seen: MutSet::default(),
|
seen: MutSet::default(),
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(rec_var) = opt_rec_var {
|
|
||||||
env.insert_seen(rec_var);
|
|
||||||
}
|
|
||||||
|
|
||||||
match tags_vec.len() {
|
match tags_vec.len() {
|
||||||
0 => {
|
0 => {
|
||||||
// trying to instantiate a type with no values
|
// trying to instantiate a type with no values
|
||||||
|
|
|
@ -6,5 +6,6 @@ procedure Test.0 ():
|
||||||
let Test.5 = 3.14f64;
|
let Test.5 = 3.14f64;
|
||||||
let Test.3 = Struct {Test.4, Test.5};
|
let Test.3 = Struct {Test.4, Test.5};
|
||||||
let Test.1 = Index 0 Test.3;
|
let Test.1 = Index 0 Test.3;
|
||||||
decref Test.3;
|
inc Test.1;
|
||||||
|
dec Test.3;
|
||||||
ret Test.1;
|
ret Test.1;
|
||||||
|
|
|
@ -12,10 +12,11 @@ procedure Test.0 ():
|
||||||
let Test.17 = lowlevel Eq Test.15 Test.16;
|
let Test.17 = lowlevel Eq Test.15 Test.16;
|
||||||
if Test.17 then
|
if Test.17 then
|
||||||
let Test.11 = Index 1 Test.2;
|
let Test.11 = Index 1 Test.2;
|
||||||
|
inc Test.11;
|
||||||
|
dec Test.2;
|
||||||
let Test.12 = 0i64;
|
let Test.12 = 0i64;
|
||||||
let Test.13 = Index 0 Test.11;
|
let Test.13 = Index 0 Test.11;
|
||||||
dec Test.11;
|
dec Test.11;
|
||||||
decref Test.2;
|
|
||||||
let Test.14 = lowlevel Eq Test.12 Test.13;
|
let Test.14 = lowlevel Eq Test.12 Test.13;
|
||||||
if Test.14 then
|
if Test.14 then
|
||||||
let Test.7 = 1i64;
|
let Test.7 = 1i64;
|
||||||
|
@ -24,5 +25,6 @@ procedure Test.0 ():
|
||||||
let Test.9 = 0i64;
|
let Test.9 = 0i64;
|
||||||
ret Test.9;
|
ret Test.9;
|
||||||
else
|
else
|
||||||
|
dec Test.2;
|
||||||
let Test.10 = 0i64;
|
let Test.10 = 0i64;
|
||||||
ret Test.10;
|
ret Test.10;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue