www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8933] New: -property switch and opDispatch for methods and properties


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

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: -------
Nov 02 2012