struct Foo { T get(T)(){ return T.init; } T func1(T)() if (__traits(compiles, get!T())) { return get!T; } T func2(T)() if (__traits(compiles, this.get!T())) // add explicit 'this' { return get!T; } } void main() { Foo foo; foo.get!int(); // OK foo.func1!int(); // OK foo.func2!int(); // NG }
D2 patch: https://github.com/D-Programming-Language/dmd/pull/524 Maybe D1 has same issue.
https://github.com/D-Programming-Language/dmd/commit/1f2c811c7d7c3dd93d74665dec230bc7c9b4ee9c