Bug 1600 – Functions taking only one array cannot be called with property syntax

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2007-10-19T21:47:00Z
Last change time
2015-06-09T01:31:21Z
Keywords
spec
Assigned to
nobody
Creator
andrei
Blocks
3107

Comments

Comment #0 by andrei — 2007-10-19T21:47:55Z
Consider: void test(int[]) {} void main() { int[] a; test(a); // fine a.test(); // fine a.test; // error! } This irregularity should be fixed. One important reason for using the property syntax is terseness.
Comment #1 by wbaxter — 2007-10-31T03:27:55Z
It's especially bad since built-in properties have the opposite restriction. { int[] a; a.sort(); // error! a.sort; // fine } Personally I think the () variety should be allowed for the built-in properties also.
Comment #2 by smjg — 2007-11-08T08:45:23Z
I personally think the () should be required in both cases. AISI a property can be used in four ways: - as an lvalue - as an rvalue - explicitly calling it with ( ) - taking the address of the getter/setter function Using it by itself as an ExpressionStatement is none of these. But it certainly seems wrong that an array property can't even be used as an rvalue: ---------- int test(int[]) { return 0; } void main() { int[] a; int b; b = test(a); // fine b = a.test(); // fine b = a.test; // error! } ---------- bz1600a.d(9): Error: no property 'test' for type 'int[]' ---------- (DMD 1.023, Windows)
Comment #3 by sandford — 2009-08-03T19:17:01Z
This works in D2.031: void foo(int[] x) {} int main(char[][] args) { auto x = new int[5]; x.foo; return 0; } So maybe this should be closed?
Comment #4 by andrei — 2009-08-24T22:20:03Z
Seems to be fixed as of 2.031.