www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7702] New: opDispatch & opCall errors

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7702

           Summary: opDispatch & opCall errors
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: michal.minich gmail.com



PDT ---
struct S {
    template opDispatch (string name) {
        void opCall (T) ()  property {}
    }
}

struct S3 {
    auto opCall (T) ()  property {
        struct S4 {
            void opDispatch (string name) ()  property {}
        }
        S4 s4;
        return s4;
    }
}
void main () {
    S s;
    s.opDispatch!"x".opCall!int;  // OK
    s.x.opCall!int;               // OK
    s.opDispatch!("x")!(int);     // parse error
    s.x!int;                      // infinite loop in dmd

    S3 s3;
    s3.opCall!int.opDispatch!("x");  // OK
    s3.opCall!int.x;                 // OK
    s3!int.x;       // Error: template instance s3!(int) s3 is not a template
declaration, it is a variable
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 13 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7702


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice



The infinite loop in dmd is the real issue.

struct S {
   template opDispatch (string name) {
       //void opCall (T) ()  property {}  // not need
   }
}
void main () {
    S s;
    s.x!int;   // infinite loop in dmd
}

And others are not errors, because their error messages are valid.
Then I replace the subject.

----

opCall works only for call syntax, e.g. rewriting foo(args) to
foo.opCall(args).

If you want to implement s.x!int with opDispatch, *nested opDispatch idiom*
like follows would work.

struct S {
    template opDispatch(string name) {
        T opDispatch(T)()  property {
            return T.init;
        }
    }
}
void main() {
    S s;
    assert(s.x!int == 0);
    // same as s.opDispatch!("x").opDispatch!(int)()
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 13 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7702


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|unspecified                 |D2
            Summary|opDispatch & opCall errors  |opDispatch goes into
                   |                            |infinite loop
           Severity|normal                      |critical


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 13 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7702


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull



https://github.com/D-Programming-Language/dmd/pull/808

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 13 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7702




Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/380b2f8a26da0cb5c6a263608efb2c7020f25c7e


Issue 7702 & 5733 - opDispatch goes into infinite loop

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 15 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7702


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


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