Bug 9884 – Refused initialization of const array in the module static this()
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2013-04-05T11:15:22Z
Last change time
2019-06-20T12:29:35Z
Keywords
pull, rejects-valid
Assigned to
No Owner
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2013-04-05T11:15:22Z
const int[] data;
static this() {
data = new int[10];
foreach (ref x; data) x = 1; // OK
data[] = 1; // Error
}
void main() {}
DMD 2.063alpha gives:
test.d(5): Error: slice data[] is not mutable
I think both ways to initialize "data" should be allowed, or both disallowed.
Comment #1 by dlang-bot — 2019-06-20T10:10:47Z
@Basile-z created dlang/dmd pull request #10067 "fix issue 9884 - Refused initialization of const array in the module static this()" fixing this issue:
- fix issue 9884 - Refused initialization of const array in the module static this()
https://github.com/dlang/dmd/pull/10067
Comment #2 by dlang-bot — 2019-06-20T12:29:35Z
dlang/dmd pull request #10067 "fix issue 9884 - Refused initialization of const array in the module static this()" was merged into master:
- 30f2cdd5725425a33e7d3d9264c01282e53d1750 by Basile Burg:
fix issue 9884 - Refused initialization of const array in the module static this()
https://github.com/dlang/dmd/pull/10067