Skip to content

Field access of explicit tag type union should prioritize definitions over tag. #959

@alexnask

Description

@alexnask

Example:

const Id = enum {
    A, B,
};

const Foo = union(Id) {
    A: A,
    B: B,

    const A = u8;
    const B = void;
};

test "union" {
    assert(Foo.A == Id.A); // This should probably return 'u8' instead of Id.A
}

Also, there should probably be some way to refer to definitions with the same symbols as the enum tags even in auto-generated tag unions (and no-tag unions), or be made a compile error (the current state where there are unreachable definitions is the problem imo).

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedThis proposal is planned.proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions