If an opDispatch function has a semantic error inside the body a misleading error will be reported at the call site. Example:
--------------------test.d----------------------
struct Foo
{
int opDispatch(string prop)() @property
{
pragma(msg, prop);
thisFunctionDoesntExist();
return 1;
}
}
void main()
{
import std.stdio;
Foo bar;
writeln(bar.baz);
}
-------------------------------------------------
Run:
dmd test.d && ./test
baz
test.d(15): Error: undefined identifier 'baz'
The pragma clearly shows that opDispatch template is being instantiated, but it seems to bail when an error is encountered, leading to the "undefined identifier" error.
Comment #1 by daniel350 — 2012-09-22T03:24:53Z
*** Issue 8547 has been marked as a duplicate of this issue. ***
Comment #2 by yebblies — 2013-11-16T21:06:38Z
*** Issue 10546 has been marked as a duplicate of this issue. ***
Comment #3 by yebblies — 2013-11-16T21:06:40Z
*** Issue 10760 has been marked as a duplicate of this issue. ***
Comment #4 by yebblies — 2013-11-16T21:08:52Z
*** Issue 8097 has been marked as a duplicate of this issue. ***
Comment #5 by simen.kjaras — 2018-05-16T13:28:25Z
*** This issue has been marked as a duplicate of issue 14145 ***