Why opDispatch uses SFINAE implicitly?

Adam D. Ruppe via Digitalmars-d digitalmars-d at puremagic.com
Thu Mar 2 10:17:05 PST 2017


On Thursday, 2 March 2017 at 06:40:29 UTC, Dukc wrote:
> If I define an opDispatch for something, but the call does not 
> compile, the compiler currently behaves as if the opDispatch 
> didn't exist at all.

I think this is actually an accident of implementation, because 
when it was new, it actually did error out, but then it wouldn't 
check other things like alias this. So they fixed one bug, but 
introduced this....

It is really annoying, even a typo inside opDispatch can cause it 
to fail to compile and just be removed from consideration.

At the call point, if you get "no such property" when you 
expected opDispatch, you can rewrite it manually to 
`obj.opDispatch!"name"`, recompile, and see the actual error.

But otherwise, I don't know of any trick to get it. I call it a 
compiler error message bug. (we're starting to have a LOT of them)


More information about the Digitalmars-d mailing list