www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13612] New: Wrong 'this' variable accessed in recursive ctfe


          Issue ID: 13612
           Summary: Wrong 'this' variable accessed in recursive ctfe
                    member function
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: CTFE, wrong-code
          Severity: major
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: yebblies gmail.com

class S
    int x;
    int recurse()
        S s;
        assert(!x); // Error: class 'this' is null and cannot be dereferenced
        s = new S();
        return s.recurse();

static assert(new S().recurse());

In the interpreter's visit(ThisExp), the first branch for localThis is not
taken because localThis is a VarExp, not a StructLiteralExp.

Oct 13 2014