Bug 16433 – __traits(compiles) inconsistent for child class

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2016-08-26T11:03:43Z
Last change time
2024-12-13T18:49:47Z
Assigned to
No Owner
Creator
ryan
Moved to GitHub: dmd#19180 →

Comments

Comment #0 by ryan — 2016-08-26T11:03:43Z
--- 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
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19180 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB