D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3448 - `__traits(compiles, <uncompilable template>)` is true and doesn't gap errors if not in a function
Summary: `__traits(compiles, <uncompilable template>)` is true and doesn't gap errors ...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-29 04:48 UTC by Max Samukha
Modified: 2017-09-19 08:15 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Max Samukha 2009-10-29 04:48:13 UTC
template Bar()
{
    void Bar()
    {
        error;
    }
}

template Foo()
{
    enum Foo = __traits(compiles, Bar!());
}

static assert(!Foo!());
Comment 1 yebblies 2011-06-12 15:27:30 UTC
This seems to have the same root cause as bug 965
Comment 2 Denis Shelomovskii 2012-01-01 02:20:05 UTC
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 Denis Shelomovskii 2012-01-01 02:35:40 UTC
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 John Hall 2016-04-08 12:28:00 UTC
Discussion related to this bug:
https://forum.dlang.org/post/pjztqzrovuafonoeusnm@forum.dlang.org
Comment 5 Simen Kjaeraas 2017-09-19 08:15:26 UTC
All asserts in this issue pass under 2.075.1. Closing.