Fix #21020 - Indexing a *cast* AA yields no lvalue anymore (#21029)

This commit is contained in:
Martin Kinkelin 2025-03-19 00:15:23 +01:00 committed by GitHub
parent 6d57da76e4
commit 8db14cf846
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View file

@ -3632,6 +3632,7 @@ extern (C++) final class CastExp : UnaExp
if (rvalue || !e1.isLvalue())
return false;
return (to.ty == Tsarray && (e1.type.ty == Tvector || e1.type.ty == Tsarray)) ||
(to.ty == Taarray && e1.type.ty == Taarray) ||
e1.type.mutableOf.unSharedOf().equals(to.mutableOf().unSharedOf());
}

View file

@ -0,0 +1,11 @@
// https://github.com/dlang/dmd/issues/21020
shared struct Queue {
int[int] map;
}
void main() {
auto queue = Queue();
(cast(int[int]) queue.map)[1] = 2;
assert(queue.map[1] == 2);
}