Skip to content

tuple of enum created with @Type and single field can't be initialized #19985

Closed
@travisstaloch

Description

@travisstaloch

Zig Version

0.13.0-dev.75+5c9eb4081

Steps to Reproduce and Observed Behavior

/tmp/tmp.zig

test {
    // these work fine
    // const E = enum { foo };
    // const E = enum(u0) { foo };
    const E = @Type(.{ .Enum = .{
        .tag_type = u0,
        .is_exhaustive = true,
        .fields = &.{.{ .name = "foo", .value = 0 }},
        .decls = &.{},
    } });
    const s: struct { E } = .{.foo};
    _ = s;
}
$ zig test /tmp/tmp.zig
/tmp/tmp.zig:90:32: error: value stored in comptime field does not match the default value of the field
    const s: struct { E } = .{.foo};
                              ~^~~

Expected Behavior

This should work considering that the above works with enum { foo } and enum(u0) { foo }.

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