panic on invalid non-recursive tag union

This commit is contained in:
Folkert 2021-01-10 01:51:55 +01:00
parent 47128414d4
commit 3cbac76be8

View file

@ -960,15 +960,9 @@ pub fn build_exp_expr<'a, 'ctx, 'env>(
field_types.push(field_type); field_types.push(field_type);
if let Layout::RecursivePointer = tag_field_layout { if let Layout::RecursivePointer = tag_field_layout {
let ptr = allocate_with_refcount(env, &tag_layout, val); panic!(
r"non-recursive tag unions cannot directly contain a recursive pointer"
let ptr = cast_basic_basic(
builder,
ptr.into(),
ctx.i64_type().ptr_type(AddressSpace::Generic).into(),
); );
field_vals.push(ptr);
} else { } else {
// this check fails for recursive tag unions, but can be helpful while debugging // this check fails for recursive tag unions, but can be helpful while debugging
debug_assert_eq!(tag_field_layout, val_layout); debug_assert_eq!(tag_field_layout, val_layout);