digitalmars.D.bugs - [Issue 12951] New: Not all failures to compile opDispatch should be
- via Digitalmars-d-bugs (44/44) Jun 19 2014 https://issues.dlang.org/show_bug.cgi?id=12951
https://issues.dlang.org/show_bug.cgi?id=12951 Issue ID: 12951 Summary: Not all failures to compile opDispatch should be regarded as "field not found" Product: D Version: D2 Hardware: x86 OS: Linux Status: NEW Severity: enhancement Priority: P1 Component: DMD Assignee: nobody puremagic.com Reporter: hsteoh quickfur.ath.cx CODE: ------ struct S { int x, y, z; } struct T { S impl; auto opDispatch(string field)() { return __traits(getMember, impl, feild); // N.B. this is a typo } } void main() { T t; auto x = t.x; } ------ Compiler output: ------ test.d(13): Error: no property 'x' for type 'T' ------ Changing "feild" to "field" fixes the problem. This is not good, because the diagnostic is completely unhelpful -- there is no indication that the compile error is caused by a typo in the implementation of opDispatch. I understand that sometimes it's useful for failure to compile opDispatch to be taken as declining field dispatch (if field=="w" then the above error message would be appropriate), but this makes it nigh impossible to debug opDispatch, since the real error message has been gagged. Is there a way to gag only "no property..." errors, but leave the other errors in opDispatch ungagged? --
Jun 19 2014