void foo(T)() {
static if (!is(T : int)) {
pragma(msg, "Error message.");
}
static assert(is(T : int));
}
void main() {
assert(!is(typeof(foo!string)));
}
The above program outputs "Error message." before concluding that the function could not be instantiated. In my use case, the pragma is used to tell the user exactly what he's doing wrong, and have absolutely no use when testing if the code compiles or not.
Comment #1 by simen.kjaras — 2018-02-19T07:30:39Z
Works in 2.078.3.
Comment #2 by simen.kjaras — 2018-03-02T07:24:52Z
I was apparently a bit hasty in closing this. Encountered the same issue again today, and testing the code in comment #0 again shows that its behavior has not been fixed in 2.078.3.
Comment #3 by robert.schadek — 2024-12-13T18:14:19Z