Bug 6927 – Better @property management by chained functions
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-11-09T20:24:00Z
Last change time
2011-11-16T09:36:00Z
Keywords
patch, rejects-valid
Assigned to
nobody
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2011-11-09T20:24:15Z
I think this code is correct:
@property int[] foo() {
return [1, 2];
}
int[] bar(int[] a) {
return a;
}
void main() {
bar(foo); // OK
foo.bar(); // line 9, Error
}
But DMD 2.057head gives:
test.d(9): Error: function expected before (), not bar(foo()) of type int[]
This makes the usage of D language less uniform, because code like this is refused (and sometimes you can't replace an array attribute by a @property getter because of this):
auto sortedAKeys = a.keys.sort(); // error