Struct with opDispatch doesn't dispatch. Is this a bug?

Kenji Hara k.hara.pg at gmail.com
Thu Jul 4 23:26:42 PDT 2013


On Friday, 5 July 2013 at 03:12:44 UTC, Meta wrote:
> I wasn't 100% sure the following is a bug, so I figured I'd ask.
>
> struct Fail
> {
> 	void opDispatch(string s)()
> 	{
> 		static assert(false, "Tried to call a method on Fail");
> 	}
> }
>
> void main()
> {
>         auto fail = Fail();
>         fail.s(); //Error: no property 's' for type 'Fail'
> }

This is a compiler's diagnostic bug.
http://d.puremagic.com/issues/show_bug.cgi?id=10546

In this case, opDispatch is _actually_ instantiated. However the 
static assertion message is suppressed for later UFCS symbol 
search.
But UFCS cannot find module level function 's', then compiler 
reports irrelevant error message "no property 's'"

Kenji Hara


More information about the Digitalmars-d-learn mailing list