-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[QoI] diagnose operator fixity attrs together; improve messages #4661
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
Conversation
3da8909
to
63a38a1
Compare
@swift-ci please smoke test |
@swift-ci smoke test linux |
@@ -4488,6 +4536,9 @@ Parser::parseDeclFunc(SourceLoc StaticLoc, StaticSpellingKind StaticSpelling, | |||
GenericParams, BodyParams, Type(), FuncRetTy, | |||
CurDeclContext); | |||
|
|||
if (diagnoseOperatorFixityAttributes(*this, Attributes, FD)) | |||
FD->setInvalid(); |
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.
It doesn't seem necessary to mark the whole declaration invalid, does it?
} | ||
|
||
if (diagnoseOperatorFixityAttributes(*this, Attributes, res)) | ||
res->setInvalid(); |
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.
Same here: I don't think the whole operator declaration needs to be invalid.
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.
Fair enough — removed.
Previously, `infix` was not recognized as conflicting with `prefix` and `postfix`. We now offer to remove all but the first fixity attribute.
63a38a1
to
682ab47
Compare
@swift-ci please smoke test |
LGTM now, thanks! |
[pull] swiftwasm from main
Addresses an issue raised by @rintaro in #4628.
Previously,
infix
was not recognized as conflicting withprefix
andpostfix
. We now offer to remove all but the first fixity attribute.RFC:
I'm not sure
ParseDecl.cpp
is really the right place to check these attrs. I like the idea of havingTypeCheckAttr.cpp
contain most of the attribute-verifying logic, but it's structured as a simple visitor which doesn't have the power to handle a few related attributes at the same time (without architectural changes). Maybe I'm missing something, but to me the current distinction between things inDiagnosticsSema.def
and things inDiagnosticsParse.def
seems somewhat arbitrary.Perhaps @DougGregor or someone else can provide a better alternative.
Before:
After: