https://issues.dlang.org/show_bug.cgi?id=13612
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: [email protected]
Reporter: [email protected]
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.
--