Bug 12663 – Wrong error message for mutation of immutable static array
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2014-04-27T13:31:16Z
Last change time
2022-08-22T15:03:05Z
Keywords
diagnostic
Assigned to
No Owner
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2014-04-27T13:31:16Z
immutable static int[] data = [1];
static this() {
data.length++;
}
void main() {}
DMD 2.066alpha gives an error message that is both wrong in contents and refers to the wrong line:
test2.d(1,31): Error: constant 1u is not an lvalue
Expected is an error message like:
test2.d(3,5): Error: cannot modify immutable expression data