remove tag id from data bytes for non-recursive tags

This commit is contained in:
Folkert 2021-06-26 17:01:23 +02:00
parent 98db393587
commit 98a9dc0945
24 changed files with 188 additions and 170 deletions

View file

@ -109,6 +109,8 @@ impl<'a> UnionLayout<'a> {
pub fn layout_at(self, tag_id: u8, index: usize) -> Layout<'a> {
let result = match self {
UnionLayout::NonRecursive(tag_layouts) => {
let index = index - 1;
let field_layouts = tag_layouts[tag_id as usize];
// this cannot be recursive; return immediately
@ -1583,7 +1585,9 @@ pub fn union_sorted_tags_help<'a>(
let mut arg_layouts = Vec::with_capacity_in(arguments.len() + 1, arena);
// add the tag discriminant (size currently always hardcoded to i64)
arg_layouts.push(Layout::Builtin(TAG_SIZE));
if is_recursive {
arg_layouts.push(Layout::Builtin(TAG_SIZE));
}
for var in arguments {
match Layout::from_var(&mut env, var) {