Skip to content
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

[REG2.111] Indexing a *cast* AA yields no lvalue anymore #21020

Closed
kinke opened this issue Mar 17, 2025 · 2 comments
Closed

[REG2.111] Indexing a *cast* AA yields no lvalue anymore #21020

kinke opened this issue Mar 17, 2025 · 2 comments
Labels
Severity:Regression PRs that fix regressions

Comments

@kinke
Copy link
Contributor

kinke commented Mar 17, 2025

This works with v2.110.0, but fails to compile with v2.111.0-beta.1:

shared struct Queue
{
    int[int] map;
}

void main()
{
    auto queue = Queue();
    (cast(int[int]) queue.map)[1] = 2;
    assert(queue.map[1] == 2);
}
bug.d(9): Error: cannot modify expression `(cast(int[int])queue.map)[1]` because it is not an lvalue
@kinke
Copy link
Contributor Author

kinke commented Mar 18, 2025

AFAICT, the problem is that in

override bool isLvalue()
{
//printf("e1.type = %s, to.type = %s\n", e1.type.toChars(), to.toChars());
if (rvalue || !e1.isLvalue())
return false;
return (to.ty == Tsarray && (e1.type.ty == Tvector || e1.type.ty == Tsarray)) ||
e1.type.mutableOf.unSharedOf().equals(to.mutableOf().unSharedOf());
}
e1.type.mutableOf.unSharedOf().equals(to.mutableOf().unSharedOf()) fails for e1.type = shared(int[int]) and to.type = int[int] (e1.isLvalue() is true).

Edit: Ah, e1.type.mutableOf().unSharedOf() yields shared(int)[int].

kinke added a commit to kinke/dmd that referenced this issue Mar 18, 2025
@kinke
Copy link
Contributor Author

kinke commented Mar 18, 2025

#21029

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Severity:Regression PRs that fix regressions
Projects
None yet
Development

No branches or pull requests

2 participants