www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16468] New: __traits(compiles, ...) doesn't work for super,

https://issues.dlang.org/show_bug.cgi?id=16468

          Issue ID: 16468
           Summary: __traits(compiles, ...) doesn't work for super, always
                    evaluates false
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: meapineapple gmail.com

It seems that __traits cannot be used to check correctness of a super ctor
call, instead always returns false.

class Base{
    this(int x){}
}
class Sub: Base{
    this(int x){
        pragma(msg, __traits(compiles, {super(x);})); // false
        super(x); // yet compiles
    }
}
void main(){
    new Sub(10);
}

--
Sep 05 2016