Comment #0 by qs.il.paperinik — 2017-06-30T00:20:12Z
mixin template Test(alias f)
{
import std.traits : ReturnType;
alias R = ReturnType!f;
R foo() { }
}
struct S
{
void foo(int) { }
mixin Test!foo T;
alias foo = T.foo;
}
gives me the error message "template instance std.traits.ReturnType!(foo) is used as a type"
However, when R foo() { } is replaced with ReturnType!f foo() { } the error message is "isCallable!(foo) is not an expression", and if one deletes the alias for R, the error disappears.
Instead, if I precede the mixin template with "import std.traits : isCallable;" and constrain it with "if (isCallable!f)", the error is "no property 'foo' for type 'void'" essentially because it cannot instance isCallable!f for whatever reason.
I suspect it is a bug in DMD. It could be in Phobos's ReturnType or isCallable.
Comment #1 by robert.schadek — 2024-12-13T18:52:56Z