[Issue 965] `is(<uncompilable template>)` is true and doesn't gap errors if not in a function

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jan 1 02:59:37 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=965


Denis <verylonglogin.reg at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |verylonglogin.reg at gmail.com
           Platform|x86                         |All
            Version|1.005                       |D1 & D2
            Summary|incorrect result for        |`is(<uncompilable
                   |"is(BadTemplate!())"        |template>)` is true and
                   |                            |doesn't gap errors if not
                   |                            |in a function
         OS/Version|Linux                       |All


--- Comment #3 from Denis <verylonglogin.reg at gmail.com> 2012-01-01 13:59:08 MSK ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list