[Issue 14145] opDispatch not considered when function body doesn't compile
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Sep 3 19:18:31 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=14145
Steven Schveighoffer <schveiguy at yahoo.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |schveiguy at yahoo.com
--- Comment #9 from Steven Schveighoffer <schveiguy at yahoo.com> ---
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.
--
More information about the Digitalmars-d-bugs
mailing list