Skip to content

Conversation

poypoyan
Copy link
Contributor

@poypoyan poypoyan commented Apr 27, 2025

Fixes: #22506

The main fix is to replace return Entry{ with just return .{ in iterator.next() of EnumArray. The prior should actually work, but I think there is a deeper bug here: I see 3 "variants" of issue #19985:

const E = @Type(.{ .Enum = .{
    .tag_type = u0,
    .is_exhaustive = true,
    .fields = &.{.{ .name = "foo", .value = 0 }},
    .decls = &.{},
} });

const s: struct { E } = .{.foo};   // 1) original of #19955. compiles.
const s = struct { k: E }{ .k = .foo };   // 2) minimal replication of the current issue. does not compile!
const s: struct { k: E } = .{ .k = .foo };   // 3) minimal replication of my fix. compiles.

Thus my change in test/behavior/type.zig is to add variant 3) alongside 1). I am not knowledgeable in how compiler works so I cannot investigate further on why 2) doesn't work.

Other changes:

  • Moved EnumSet tests below EnumSet function.
  • Add test for the current issue below EnumArray function.

@poypoyan poypoyan closed this Jun 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

std.meta.FieldEnum for type with one field does not work in std.EnumArray

1 participant