mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 08:34:33 +00:00
remove field
This commit is contained in:
parent
4dd7ea1356
commit
c8970bbe45
4 changed files with 8 additions and 13 deletions
|
@ -1044,7 +1044,6 @@ pub fn build_exp_expr<'a, 'ctx, 'env>(
|
||||||
tag_layout:
|
tag_layout:
|
||||||
Layout::Union(UnionLayout::NullableWrapped {
|
Layout::Union(UnionLayout::NullableWrapped {
|
||||||
nullable_id,
|
nullable_id,
|
||||||
nullable_layout: _,
|
|
||||||
other_tags: fields,
|
other_tags: fields,
|
||||||
}),
|
}),
|
||||||
union_size,
|
union_size,
|
||||||
|
|
|
@ -1014,16 +1014,17 @@ fn path_to_expr_help<'a>(
|
||||||
NonRecursive(layouts) | Recursive(layouts) => layouts[*tag_id as usize],
|
NonRecursive(layouts) | Recursive(layouts) => layouts[*tag_id as usize],
|
||||||
NullableWrapped {
|
NullableWrapped {
|
||||||
nullable_id,
|
nullable_id,
|
||||||
nullable_layout,
|
|
||||||
other_tags: layouts,
|
other_tags: layouts,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
dbg!(nullable_id, tag_id);
|
dbg!(nullable_id, tag_id);
|
||||||
match (*tag_id as usize).cmp(&(*nullable_id as usize)) {
|
match (*tag_id as usize).cmp(&(*nullable_id as usize)) {
|
||||||
Ordering::Equal => &*env
|
Ordering::Equal =>
|
||||||
|
// the nullable tag is going to predent it stores a tag id
|
||||||
|
&*env
|
||||||
.arena
|
.arena
|
||||||
.alloc([Layout::Builtin(nullable_layout.clone())]),
|
.alloc([Layout::Builtin(crate::layout::TAG_SIZE)]),
|
||||||
Ordering::Less => layouts[*tag_id as usize],
|
Ordering::Less => layouts[*tag_id as usize],
|
||||||
Ordering::Greater => layouts[*tag_id as usize - 1],
|
Ordering::Greater => layouts[*tag_id as usize - 1],
|
||||||
}
|
}
|
||||||
|
|
|
@ -2823,7 +2823,6 @@ pub fn with_hole<'a>(
|
||||||
|
|
||||||
let layout = Layout::Union(UnionLayout::NullableWrapped {
|
let layout = Layout::Union(UnionLayout::NullableWrapped {
|
||||||
nullable_id,
|
nullable_id,
|
||||||
nullable_layout: TAG_SIZE,
|
|
||||||
other_tags: layouts.into_bump_slice(),
|
other_tags: layouts.into_bump_slice(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -6169,7 +6168,6 @@ fn from_can_pattern_help<'a>(
|
||||||
|
|
||||||
let layout = Layout::Union(UnionLayout::NullableWrapped {
|
let layout = Layout::Union(UnionLayout::NullableWrapped {
|
||||||
nullable_id,
|
nullable_id,
|
||||||
nullable_layout: TAG_SIZE,
|
|
||||||
other_tags: layouts.into_bump_slice(),
|
other_tags: layouts.into_bump_slice(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -50,12 +50,11 @@ pub enum UnionLayout<'a> {
|
||||||
/// see also: https://youtu.be/ip92VMpf_-A?t=164
|
/// see also: https://youtu.be/ip92VMpf_-A?t=164
|
||||||
NullableWrapped {
|
NullableWrapped {
|
||||||
nullable_id: i64,
|
nullable_id: i64,
|
||||||
nullable_layout: Builtin<'a>,
|
|
||||||
other_tags: &'a [&'a [Layout<'a>]],
|
other_tags: &'a [&'a [Layout<'a>]],
|
||||||
},
|
},
|
||||||
// A recursive tag union where the non-nullable variant does NOT store the tag id
|
// A recursive tag union where the non-nullable variant does NOT store the tag id
|
||||||
// e.g. `ConsList a : [ Nil, Cons a (ConsList a) ]`
|
// e.g. `ConsList a : [ Nil, Cons a (ConsList a) ]`
|
||||||
// NullableUnwrapped,
|
// NullableUnwrapped { nullable_id: bool, other_id: bool, other_fields: &'a [Layout<'a>], }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||||
|
@ -1090,14 +1089,14 @@ fn layout_from_flat_type<'a>(
|
||||||
if GENERATE_NULLABLE {
|
if GENERATE_NULLABLE {
|
||||||
for (index, (_name, variables)) in tags_vec.iter().enumerate() {
|
for (index, (_name, variables)) in tags_vec.iter().enumerate() {
|
||||||
if variables.is_empty() {
|
if variables.is_empty() {
|
||||||
nullable = Some((index as i64, TAG_SIZE));
|
nullable = Some(index as i64);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1129,10 +1128,9 @@ fn layout_from_flat_type<'a>(
|
||||||
tag_layouts.push(tag_layout.into_bump_slice());
|
tag_layouts.push(tag_layout.into_bump_slice());
|
||||||
}
|
}
|
||||||
|
|
||||||
let union_layout = if let Some((tag_id, tag_id_layout)) = nullable {
|
let union_layout = if let Some(tag_id) = nullable {
|
||||||
UnionLayout::NullableWrapped {
|
UnionLayout::NullableWrapped {
|
||||||
nullable_id: tag_id,
|
nullable_id: tag_id,
|
||||||
nullable_layout: tag_id_layout,
|
|
||||||
other_tags: tag_layouts.into_bump_slice(),
|
other_tags: tag_layouts.into_bump_slice(),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1607,7 +1605,6 @@ pub fn layout_from_tag_union<'a>(
|
||||||
|
|
||||||
Layout::Union(UnionLayout::NullableWrapped {
|
Layout::Union(UnionLayout::NullableWrapped {
|
||||||
nullable_id,
|
nullable_id,
|
||||||
nullable_layout: TAG_SIZE,
|
|
||||||
other_tags: tag_layouts.into_bump_slice(),
|
other_tags: tag_layouts.into_bump_slice(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue