Invalid code like the following will (correctly) fail to compile, but the error preventing it from compiling will not be shown to the user.
struct X {
T opCast(T)() {
nonexistent();
return T.init;
}
}
assert(X().to!bool == bool.init);
The compiler ought to complain about nonexistent being undefined instead of simply failing to match toImpl's template declaration.
Comment #1 by elpenguino+D — 2018-11-29T21:29:26Z
https://github.com/dlang/phobos/pull/6172 attempts to fix this, but is blocked due to missing functionality. a trait to determine if a set of arguments match a template WITHOUT attempting to instantiate is required.
Comment #2 by robert.schadek — 2024-12-01T16:32:42Z