Bug 2167 – incorrect behaviour of IsExpression on invalid template instance

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2008-06-24T06:40:00Z
Last change time
2014-02-24T15:32:55Z
Keywords
rejects-valid
Assigned to
nobody
Creator
davidl

Comments

Comment #0 by davidl — 2008-06-24T06:40:09Z
in bug: http://d.puremagic.com/issues/show_bug.cgi?id=826 a slightly modified version as following passes the test class Foo(T) { this() { unknown_identifier; } } void bar() { bool foobar = is( Foo!(int) ); assert(foobar == false); } void main() { bar(); } but the comment from Thomas Kühne not: http://dstress.kuehne.cn/compile/b/bug_e2ir_520_B.d this bug fails
Comment #1 by clugdbug — 2008-06-30T08:17:08Z
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 ***