Bug 3448 – `__traits(compiles, <uncompilable template>)` is true and doesn't gap errors if not in a function

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2009-10-29T04:48:13Z
Last change time
2017-09-19T08:15:26Z
Assigned to
No Owner
Creator
Max Samukha

Comments

Comment #0 by samukha — 2009-10-29T04:48:13Z
template Bar() { void Bar() { error; } } template Foo() { enum Foo = __traits(compiles, Bar!()); } static assert(!Foo!());
Comment #1 by yebblies — 2011-06-12T15:27:30Z
This seems to have the same root cause as bug 965
Comment #2 by verylonglogin.reg — 2012-01-01T02:20:05Z
Just a bit smaller testcase: --- void t()() { error; } static assert(!__traits(compiles, t!()())); // assertion fails static if(__traits(compiles, t!()())) { } // Error: undefined identifier ---
Comment #3 by verylonglogin.reg — 2012-01-01T02:35:40Z
This bug is only for `static assert/if` not in a function: --- void t()() { error; } void f() { static assert(!__traits(compiles, t!()())); // passes static if(__traits(compiles, t!()())) { } // no errors } ---
Comment #4 by john.michael.hall — 2016-04-08T12:28:00Z
Discussion related to this bug: https://forum.dlang.org/post/[email protected]
Comment #5 by simen.kjaras — 2017-09-19T08:15:26Z
All asserts in this issue pass under 2.075.1. Closing.