Skip to content

stage2: ICE calling @typeInfo on union with noreturn field #12459

@nektro

Description

@nektro

Zig Version

0.10.0-dev.3587+9d85335de

Steps to Reproduce

const Paint = union(enum) {
    s: noreturn,
};

test {
    _ = @typeInfo(Paint);
}

Expected Behavior

it to work or compile error

Actual Behavior

[meghan@nixos]$ ~/src/zig/build/stage3/bin/zig test test.zig 
thread 573478 panic: reached unreachable code
Analyzing test.zig: test.zig:test_0
      %5 = dbg_block_begin())
      %6 = dbg_stmt(2, 5)
      %7 = decl_val("Paint") token_offset:6:19 to :6:24
    > %8 = type_info(%7) node_offset:6:9 to :6:25
      %10 = dbg_block_end())
      %9 = ensure_result_non_error(%8) node_offset:6:9 to :6:25
      %11 = ret_tok(@Zir.Inst.Ref.void_value) token_offset:7:1 to :7:2
    For full context, use the command
      zig ast-check -t test.zig


/home/meghan/src/zig/src/type.zig:3086:16: 0xb598fa in abiAlignmentAdvanced (zig)
            => unreachable,
               ^
/home/meghan/src/zig/src/Sema.zig:29331:72: 0x11afd23 in typeAbiAlignment (zig)
    return (try ty.abiAlignmentAdvanced(target, .{ .sema_kit = sema.kit(block, src) })).scalar;
                                                                       ^
/home/meghan/src/zig/src/Sema.zig:29343:37: 0x11afb0a in unionFieldAlignment (zig)
        return sema.typeAbiAlignment(block, src, field.ty);
                                    ^
/home/meghan/src/zig/src/Sema.zig:14108:67: 0xf663f8 in zirTypeInfo (zig)
                    .Auto, .Extern => try sema.unionFieldAlignment(block, src, field),
                                                                  ^
^C

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorfrontendTokenization, parsing, AstGen, Sema, and Liveness.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions