www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15623] New: is(M!N) evaluates to true for M!N that fails to

https://issues.dlang.org/show_bug.cgi?id=15623

          Issue ID: 15623
           Summary: is(M!N) evaluates to true for M!N that fails to
                    instantiate.
           Product: D
           Version: D2
          Hardware: x86_64
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: epi atari8.info

struct HasFoo { void foo() {} }

struct NoFoo {}

struct CallsFoo(T) {
    T t;
    void bar() { t.foo(); }
}

static assert(is(CallsFoo!HasFoo));
static assert(is(typeof({ alias Baz = CallsFoo!HasFoo; return Baz.init; }())));
static assert(__traits(compiles, { alias Baz = CallsFoo!HasFoo; return
Baz.init; }()));
alias Bar = CallsFoo!HasFoo;

// this should fail:
static assert(is(CallsFoo!NoFoo));
// this should fail too:
static assert(is(typeof({ alias Baz = CallsFoo!NoFoo; return Baz.init; }())));
// this too:
static assert(__traits(compiles, { alias Baz = CallsFoo!NoFoo; return Baz.init;
}()));
// only this fails:
//alias Baz = CallsFoo!NoFoo;      // (1)

--
Jan 29