fix block_of_memory creation for recursive layouts

This commit is contained in:
Folkert 2021-01-16 20:58:36 +01:00
parent c8970bbe45
commit 2ce35cca28
6 changed files with 140 additions and 84 deletions

View file

@ -1020,15 +1020,31 @@ fn path_to_expr_help<'a>(
use std::cmp::Ordering;
dbg!(nullable_id, tag_id);
match (*tag_id as usize).cmp(&(*nullable_id as usize)) {
Ordering::Equal =>
// the nullable tag is going to predent it stores a tag id
Ordering::Equal =>
// the nullable tag is going to predent it stores a tag id
{
&*env
.arena
.alloc([Layout::Builtin(crate::layout::TAG_SIZE)]),
.arena
.alloc([Layout::Builtin(crate::layout::TAG_SIZE)])
}
Ordering::Less => layouts[*tag_id as usize],
Ordering::Greater => layouts[*tag_id as usize - 1],
}
}
NullableUnwrapped {
nullable_id,
other_id: _,
other_fields,
} => {
let tag_id = *tag_id == 0;
if tag_id == *nullable_id {
// the nullable tag is going to predent it stores a tag id
&[] as &[_]
} else {
other_fields
}
}
}
}