Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

instantiated template using __traits(compiles, ...) causes semantic errors when reused #17651

Open
dlangBugzillaToGithub opened this issue Apr 6, 2014 · 1 comment

Comments

@dlangBugzillaToGithub
Copy link

det reported this on 2014-04-06T16:39:50Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=12533

Description

compilation fails for no reason in given example involving a template using mixin, static if and __traits(compiles, ...) code reflection. see details in example as it is too complicated to describe.

might be related to issue 12532. however, example fails as well when 'enum' is replaced by 'const'

=== EXAMPLE ===

template valid(string mem){
    pragma(msg, "instantiation of valid with: "~mem);
    static if( !__traits( compiles, mixin(mem) ) ){
        enum valid = false;
    }else{
        enum valid =  true;
     }
}

enum works = valid!"fails";
pragma(msg, "found 'fails' (via 'works')? "~works.stringof );
// compiles but produces 'false': issue 12532

enum dummy = valid!"fails";
pragma(msg, "found 'fails' (via 'dummy')? "~dummy.stringof );
// compiles but produces 'false': issue 12532

enum fails = valid!"fails";
// Error: variable demo.fails had semantic errors when compiling
// NOTE: if you comment out the first two usages of valid!"fails",
// it will work here - but give 'false' again.

//  pragma(msg, "found 'fails' (via 'fails')? "~fails.stringof );

void main(){}
@dlangBugzillaToGithub
Copy link
Author

2krnk commented on 2014-04-07T22:50:35Z

(In reply to comment #0)

might be caused by issue 12541.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant