Thread overview
for fun, if questionable - a heisenbug
Apr 08, 2014
captaindet
Apr 08, 2014
Matej Nanut
Apr 08, 2014
captaindet
April 08, 2014
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(){}
April 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.
April 08, 2014
On 2014-04-08 15:37, Matej Nanut wrote:
> 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.

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.