www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14262] New: [REG] [2.067-b3] Can't use class `this` as ref


          Issue ID: 14262
           Summary: [REG] [2.067-b3] Can't use class `this` as ref
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: public dicebot.lv

This code compiles fine in 2.066.1 :

class A
    int opApply(int delegate(ref A obj) dg)
        return dg(this);

void main() {}

With 2.067-b3 :

./aaa.d(5): Error: delegate dg (ref A obj) is not callable using argument types

It took me some time to realize the error referred to the fact that such call
could possibly change original `this` reference which is normally not allowed
in D.

While refusing to compile this seems legit and code clearly needs fixing, error
message is not helpful at all. It should explain the issue and suggest a fix
more clearly.

Mar 08 2015