Bug 965 – `is(<uncompilable template>)` is true and doesn't gap errors if not in a function
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2007-02-15T03:44:33Z
Last change time
2017-09-19T08:14:32Z
Keywords
accepts-invalid
Assigned to
Walter Bright
Creator
Thomas Kühne
Comments
Comment #0 by thomas-dloop — 2007-02-15T03:44:33Z
This is a variation of issue #826
# class Templ(T){
# this(){
# unknown_identifier = 0;
# }
# }
#
# static assert(false == is(Templ!(int)));
bug_e2ir_520_C.d(18): static assert (0 == 1) is false
test case:
http://dstress.kuehne.cn/compile/b/bug_e2ir_520_B.d
Comment #1 by bugzilla — 2007-08-12T21:56:35Z
This is happening because compiling this()'s body is not necessary to determine the type. Not sure if this is a bug or not.
Comment #2 by samukha — 2009-10-28T06:58:04Z
*** Issue 3416 has been marked as a duplicate of this issue. ***
Comment #3 by verylonglogin.reg — 2012-01-01T02:59:08Z
This code compiles:
---
struct S() { void f() { error; } }
void f() {
static assert(!is(S!())); // passes
static if(is(S!())) { } // no errors
}
---
This bug is only for `is()` not in a function:
---
struct S() { void f() { error; } }
static assert(!is(S!())); // assertion fails
static if(is(S!())) { } // Error: undefined identifier
---
(In reply to comment #1)
> This is happening because compiling this()'s body is not necessary to determine
> the type. Not sure if this is a bug or not.
This is a bug because an assertion passes in a function and because of "undefined identifier" error with `static if`.
Someone familiar with dmd internals, mark bug 3448 as a duplicate or show the difference between `is(...)` and `__traits(compiles, ...)` in context of this issue.
Comment #4 by clugdbug — 2012-02-24T00:38:36Z
*** Issue 5352 has been marked as a duplicate of this issue. ***
Comment #5 by clugdbug — 2012-11-21T00:47:55Z
*** Issue 2167 has been marked as a duplicate of this issue. ***
Comment #6 by simen.kjaras — 2017-09-19T08:14:32Z
All asserts in this issue pass under 2.075.1. Closing.