[Issue 8933] New: -property switch and opDispatch for methods and properties

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Nov 2 02:15:41 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8933

           Summary: -property switch and opDispatch for methods and
                    properties
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: johnch_atms at hotmail.com


--- Comment #0 from johnch_atms at hotmail.com 2012-11-02 02:14:39 PDT ---
When the -property compiler switch is in effect, opDispatch cannot be used for
both methods and properties.

Currently, we can just omit the switch and things work fine. But if the
behaviour of the switch becomes the norm, this issue will have to be addressed.

struct Demo {
  @property auto opDispatch(string name, A...)(auto ref A args) {}
}

void main() {
  Demo d;
  d.test(1);     // method call OK
  d.test(1,2);   // ditto
  d.test = 4;    // property setter OK
  d.test(1,2,3); // error, properties can only have zero, one, or two parameter
}

If you omit the @property attribute from the opDispatch definition, the
compiler complains 'not a property d.opDispatch!("test")'.

Perhaps the simplest fix would be for opDispatch to be excluded from any
property rules altogether.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list