Bug 3927 – array.length++; is an error, but ++array.length compiles
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-03-10T10:12:00Z
Last change time
2012-04-11T01:02:09Z
Keywords
diagnostic, rejects-valid
Assigned to
yebblies
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2010-03-10T10:12:01Z
With the following D2 program:
void main() {
int[] array;
array.length++;
array.length--;
}
The compiler shows the following errors, is this correct?
test1.d(3): Error: a.length is not an lvalue
test1.d(4): Error: a.length is not an lvalue
Comment #1 by clugdbug — 2012-02-01T04:27:31Z
++array.length;
compiles. The bizarre error is because of the lowering that the compiler uses internally.