---
class Parent {
int x;
void fun() {
pragma(msg, "Parent method scope: " ~
__traits(compiles, this.x = this.x).stringof); // true
}
pragma(msg, "Parent class scope: " ~
__traits(compiles, this.x = this.x).stringof); // true
}
class Child : Parent {
void dun() {
pragma(msg, "Child method scope: " ~
__traits(compiles, this.x = this.x).stringof); // true
}
pragma(msg, "Child class scope: " ~
__traits(compiles, this.x = this.x).stringof); // false
}
---
I would expect that the second __traits(compiles) (inside Parent, but outside
any function) would return false, as this.x = this.x is not valid in that scope.
If it should return true for some reason, presumably that would also be the case
in the Child.
Comment #1 by robert.schadek — 2024-12-13T18:49:47Z