mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
fix for when C has to return an empty tag union
This commit is contained in:
parent
b6bae82913
commit
edf557e480
2 changed files with 24 additions and 7 deletions
|
@ -65,6 +65,7 @@ pub fn struct_type_from_union_layout<'a, 'ctx, 'env>(
|
|||
use UnionLayout::*;
|
||||
|
||||
match union_layout {
|
||||
NonRecursive([]) => env.context.struct_type(&[], false),
|
||||
NonRecursive(tags) => {
|
||||
RocUnion::tagged_from_slices(layout_interner, env.context, tags, env.target_info)
|
||||
.struct_type()
|
||||
|
@ -300,7 +301,8 @@ impl<'ctx> RocUnion<'ctx> {
|
|||
target_info: TargetInfo,
|
||||
) -> Self {
|
||||
let tag_type = match layouts.len() {
|
||||
0..=255 => TagType::I8,
|
||||
0 => unreachable!("zero-element tag union is not represented as a RocUnion"),
|
||||
1..=255 => TagType::I8,
|
||||
_ => TagType::I16,
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue