Skip to content

[REG master] Wrong associative array access with alias this for key #22281

@tim-dlang

Description

@tim-dlang

The following code fails on DMD master:

struct A
{
    bool extra;
    uint id;
}

struct B
{
    uint id;

    A toA() const pure nothrow
    {
        return A(false, id);
    }

    alias toA this;
}

void main()
{
    bool[A] aa;
    aa[B(5)] = true;
    assert(A(false, 5) in aa);
    assert(B(5) in aa);
}

The code fails since commit c31f959, but worked before.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions