Bug 3857 – Write property for arrays does not work properly
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
Other
OS
All
Creation time
2010-02-26T14:08:00Z
Last change time
2015-06-09T01:27:38Z
Assigned to
andrei
Creator
schveiguy
Comments
Comment #0 by schveiguy — 2010-02-26T14:08:01Z
If I were to define a write property for arrays foo that takes an int arg, none of the following prototypes work:
main code:
int[] x;
x.foo = 1;
test cases:
@property void foo(T)(T[] arr, int x) {}
or
void foo(T)(T[] arr, int x) {}
outputs:
testbug.d(10): Error: template testbug.foo(T) does not match any function template declaration
testbug.d(10): Error: template testbug.foo(T) cannot deduce template function from argument types !()(int[])
testbug.d(10): Error: x.foo is not an lvalue
test case:
@property void foo(int[] arr, int x) {}
outputs:
testbug.d(4): Error: properties can only have zero or one parameter
test case:
void foo(int[] arr, int x) {}
outputs:
testbug.d(10): Error: function testbug.foo (int[] arr, int x) is not callable using argument types (int[])
testbug.d(10): Error: expected 2 function arguments, not 1
testbug.d(10): Error: x.foo is not an lvalue
testbug.d(10): Error: cannot implicitly convert expression (1) of type int to void
I think at least the two variations that use @property should work. They are pretty unambiguous.
This is blocking my work on the array pre-allocate patch.
Comment #1 by schveiguy — 2010-03-15T13:07:27Z
Downgrading severity. This is no longer blocking the array append work, since it was determined that a property was not the best syntax.
I still think this should work.
Comment #2 by andrej.mitrovich — 2012-10-21T20:14:21Z