Skip to content

std.EnumArray: edit return of iterator.next() #23701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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.

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