Thread overview | |||||
---|---|---|---|---|---|
|
September 07, 2005 DMD 0.130: Properties don't access opIndexAssign overload | ||||
---|---|---|---|---|
| ||||
This code fails compilation with the error message "p.property()[4]" is not an lvalue. It is valid code. struct Array { int opIndex (int a) { return a; } int opIndexAssign (int a, int b) { return a; } } struct Property { Array property () { Array a; return a; } } void test () { Property p; p.property [4] = 8; } |
September 08, 2005 Re: DMD 0.130: Properties don't access opIndexAssign overload | ||||
---|---|---|---|---|
| ||||
Posted in reply to Burton Radons | Burton Radons wrote:
> This code fails compilation with the error message "p.property()[4]" is not
> an lvalue. It is valid code.
>
> struct Array
> {
> int opIndex (int a) { return a; }
> int opIndexAssign (int a, int b) { return a; }
> }
> struct Property
> {
> Array property () { Array a; return a; }
> }
> void test ()
> {
> Property p;
> p.property [4] = 8;
> }
>
>
This is an old bug. The workaround I used is to write parentheses explicitly like p.property()[4] = 8;
|
Copyright © 1999-2021 by the D Language Foundation