-
-
Notifications
You must be signed in to change notification settings - Fork 609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve failing foreach reporting for struct and class aggregates #3606
Conversation
|
I don't think this is right. If you want to use opApply or a range .tupleof is likely not what you wanted. |
|
I don't understand what you mean with opApply or range. What role does opApply play here and what has ranges to do with classes or structs? Could you elaborate a bit, please? |
|
If someone has tried to do |
|
Aha, wasn't aware of that. What about suggesting (in error message) both my current proposal together with an alternative to add an opApply() definition? |
|
I updated the reporting to provide hints for implementing opApply aswell. Could somebody explain why this is failing? I've not been able to run the |
|
The error message should still start with, well, an actual error message. Right now, it only consists of suggested fixes. Maybe something like Still not sure about featuring |
|
At a guess, it could be failing because there is a code path that returns I don't think slapping |
|
Too verbose diagnostic message is rather harmful. How about? const char *s = "";
if (aggr->type && isAggregate(aggr->type))
s = " (define opApply, range primitives, or use .tupleof)";
error("invalid foreach aggregate %s%s", aggr->toChars(), s); |
| else if (aggr->type->ty == Tclass) | ||
| { | ||
| error("either suffix foreach aggregate %s with .tupleof or implement class %s's member int opApply(int delegate(ref Type [, ...]) dg)", aggr->toChars(), aggr->type->toChars()); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In else branch, no error is reported but this ForeachStatement::semantic will return ErrorStatement. It is the reason of Auto-tester breaking.
|
Great! I'll look into it! |
16989bf to
dba9f2e
Compare
|
I used comma as separator as this is more in line with other messages such as the one introduced in http://dlang.org/changelog.html#warn_unused_retval I believe this is ready for merge. |
|
This passed on all targets yesterday. Can somebody explain why it doesn't on Win64 anymore? |
|
|
:) All is well again. BTW: Should I squash commits? |
|
Yes. |
Alternative warning Better message Use comma instead of parenthesis for extra tip
|
Squash done. |
|
LGTM. |
|
Auto-merge toggled on |
|
Thanks. |
Improve failing foreach reporting for struct and class aggregates
Remove useless conditional assignment of DISABLED_TESTS
Should I, similarly for enums, add tip for
__traits(members)?