Skip to content

A tuple holding Unit crashes codegen (LLVM getTypeSizeInBits on void) #1994

Closed

Description

@ehartford

Found while fixing #1964; reproduces on the fix-1438 base stage1 and on the installed compiler (not introduced by #1964).

fn unit() -> Unit: ()
fn main:
    let t: (Unit, i32) = (unit(), 5)
    print(f"{t.1}")
    var v: Vec[(i32, Unit)] = Vec.new()
    v.push((1, unit()))
    print(f"{v.len()}")

with check says ok; with build/run dies with SIGTRAP (rc 133) in llvm::DataLayout::getTypeSizeInBits — a void LLVM type reaches a size query. Expected: 5, 1. Spec §1/with-abi.md §1 give Unit zero size in a layout, so TypeLayout places (Unit, i32) as 4 bytes with both elements at 0; codegen's tuple body (#1964 tuple_type_from_layout) has no member for a zero-size element, so whatever fix lands must give the element a zero-size representation, not the i32 value carrier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions