digitalmars.D.bugs - [Issue 9319] New: Unexpected compiles __traits behaviour in a certain situation
- d-bugmail puremagic.com Jan 14 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9319 Summary: Unexpected compiles __traits behaviour in a certain situation Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: critical Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: puneet coverify.org --- Comment #0 from Puneet Goel <puneet coverify.org> 2013-01-14 11:12:38 PST --- "static if" on the line number 3 should take the else branch, but it does not and compilation actually fails on line number 6, giving me error: Error: this for foo needs to be type Derived not type Base BTW, it is failing for nested (inside base class) template, but seems to work fine for function template (line 16). class Base { // 1 template Bar(alias F) { // 2 static if(__traits(compiles, F())) { // 3 pragma(msg, F.stringof ~ " compiles here"); // prints this // 4 class Bar { // 5 this() { F(); } // but actual compilation fails // 6 } // 7 } else { // 8 pragma(msg, F.stringof ~ " does not compile"); // 9 class Bar { // 10 this() { } // 11 } // 12 } // 13 } // 14 // 15 public void bar(alias F)() { // 16 static if(__traits(compiles, F())) { // works as expected // 17 F(); // 18 } // 19 } // 20 } // 21 // 22 class Derived: Base { // 23 public void foo() {} // 24 public Bar!foo boo; // 25 public void frop() { // 26 bar!foo; // 27 boo = new Bar!foo; // 28 } // 29 } // 30 // 31 void main() { // 32 auto obj = new Derived; // 33 obj.frop(); // 34 } // 35 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 14 2013








d-bugmail puremagic.com