D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6927 - Better @property management by chained functions
Summary: Better @property management by chained functions
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: patch, rejects-valid
Depends on:
Blocks:
 
Reported: 2011-11-09 20:24 UTC by bearophile_hugs
Modified: 2011-11-16 09:36 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2011-11-09 20:24:15 UTC
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