Skip to content

Commit 8db14cf

Browse files
authored
Fix #21020 - Indexing a *cast* AA yields no lvalue anymore (#21029)
1 parent 6d57da7 commit 8db14cf

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

compiler/src/dmd/expression.d

+1
Original file line numberDiff line numberDiff line change
@@ -3632,6 +3632,7 @@ extern (C++) final class CastExp : UnaExp
36323632
if (rvalue || !e1.isLvalue())
36333633
return false;
36343634
return (to.ty == Tsarray && (e1.type.ty == Tvector || e1.type.ty == Tsarray)) ||
3635+
(to.ty == Taarray && e1.type.ty == Taarray) ||
36353636
e1.type.mutableOf.unSharedOf().equals(to.mutableOf().unSharedOf());
36363637
}
36373638

compiler/test/runnable/test21020.d

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// https://github.com/dlang/dmd/issues/21020
2+
3+
shared struct Queue {
4+
int[int] map;
5+
}
6+
7+
void main() {
8+
auto queue = Queue();
9+
(cast(int[int]) queue.map)[1] = 2;
10+
assert(queue.map[1] == 2);
11+
}

0 commit comments

Comments
 (0)