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

Steven Schveighoffer <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #9 from Steven Schveighoffer <[email protected]> ---
Ran into this recently also.

What I have been doing to figure out why it's not working is to explicitly call
opDispatch:

A.init.opDispatch!"foo"();

IMO, if no other valid members exist, then opDispatch should be used, even if
it doesn't compile (and the subsequent error message printed).

I can see the utility in something like:

struct A
{
   T wrapped;
   auto opDispatch(string m, Args...)(Args args) {
       mixin("return wrapped." ~ m ~ "(args);");
   }
}

Without having to use a constraint to ensure the call is possible. But the cost
for this is pretty steep (confusing and misleading error messages). Whether
opDispatch is *matched* or not should not depend on the body, only the
signature and constraints. This is in line with all other function templates.

--

Reply via email to