digitalmars.D - for fun, if questionable - a heisenbug
- captaindet (14/14) Apr 08 2014 reported as part of issue 12541
- Matej Nanut (3/4) Apr 08 2014 I noticed it works if you move the enum declaration above the
- captaindet (2/6) Apr 08 2014 yes, it requires certain conditions to (dis)appear. those i could figure...
reported as part of issue 12541 https://d.puremagic.com/issues/show_bug.cgi?id=12541 === CODE === module heisenbug; // pragma(msg, __traits(compiles, test) ); // comment in the pragma and 'enum buggy' below will compile fine enum buggy = valid!(test); // Error: variable heisenbug.buggy had semantic errors when compiling pragma(msg, "buggy = "~buggy.stringof); enum test = 13; template valid(alias sym){ enum valid = __traits(compiles, sym); } // no difference if this template is declared first void main(){}
Apr 08 2014
On 8 April 2014 22:11, captaindet <2krnk gmx.net> wrote:[...]I noticed it works if you move the enum declaration above the instantiation of template valid.
Apr 08 2014
On 2014-04-08 15:37, Matej Nanut wrote:On 8 April 2014 22:11, captaindet<2krnk gmx.net> wrote:yes, it requires certain conditions to (dis)appear. those i could figure out are in the bug report ( https://d.puremagic.com/issues/show_bug.cgi?id=12541 ). also, of course, if the _traits method is not templated, it always compiles fine. unfortunately, if you want to apply meta stuff on arbitrary/other ppls code, you don't have the luxury of moving declarations around.[...]I noticed it works if you move the enum declaration above the instantiation of template valid.
Apr 08 2014