I think this *is* returning the correct result. The only issue is, that although the template instantiation fails, no error message is printed. (just "static assert is false"). But static assert is a bit wierd (and not terribly useful any more), so I'm not even certain that it is a bug.
Comment #2 by 2korden — 2008-06-30T08:34:10Z
Let me rephrase:
class Templ(T) { this(){ unknown_identifier; } }
void main() {
static assert(false == is(Templ!(int))); // correctly passes
}
static assert(false == is(Templ!(int))); // fails, yet they are the same, the only difference is a scope
Comment #3 by 2korden — 2008-06-30T08:49:53Z
The following one fails to compile:
class Templ(T) { this(){ unknown_identifier; } }
static assert(true == is(Templ!(int)));
with the following reason:
Error: undefined identifier unknown_identifier
And so does this:
static assert(true == __traits(compiles, Templ!(int)));
IMO, incorrect code in __traits(compiles) should not lead to compilation errors.
Comment #4 by davidl — 2008-07-01T12:06:02Z
as Koroskin Denis rephrased, it's clearly a misbehavior.
Comment #5 by smjg — 2008-11-24T07:15:08Z
The original issue isn't a bug, since the point of IsExpression is that semantic errors never escape it - it just evaluates to false instead.
But the issue raised from comment 2 onwards is certainly a bug, and the behaviour is quite strange.
----------
import std.stdio;
class Templ(T) { this(){ unknown_identifier; } }
void main() {
pragma(msg, "In main: " ~ is(Templ!(int)).stringof);
}
----------
In main: 0
----------
But add this line at the very end
pragma(msg, "Global: " ~ is(Templ!(int)).stringof);
----------
Global: 1
In main: 1
bz2167a.d(2): Error: undefined identifier unknown_identifier
bz2167a.d(2): Error: identifier has no effect in expression (unknown_identifier)
----------
Comment #6 by clugdbug — 2012-11-21T00:47:55Z
*** This issue has been marked as a duplicate of issue 965 ***