Skip to content

[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

Merged
merged 1 commit into from
Sep 22, 2016

Conversation

jtbandes
Copy link
Contributor

@jtbandes jtbandes commented Sep 7, 2016

Addresses an issue raised by @rintaro in #4628.

Previously, infix was not recognized as conflicting with prefix and postfix. 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 having TypeCheckAttr.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 in DiagnosticsSema.def and things in DiagnosticsParse.def seems somewhat arbitrary.

Perhaps @DougGregor or someone else can provide a better alternative.

Before:

no error 😱
infix prefix operator ++

attribute 'postfix' cannot be combined with this attribute
postfix prefix operator --
        ^

After:

error: 'prefix' contradicts previous modifier 'infix'
infix prefix operator ++
      ^~~~~~~

error: 'prefix' contradicts previous modifier 'postfix'
postfix prefix operator --
        ^~~~~~~

@jtbandes
Copy link
Contributor Author

jtbandes commented Sep 7, 2016

@swift-ci please smoke test

@jtbandes
Copy link
Contributor Author

jtbandes commented Sep 7, 2016

@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();
Copy link
Member

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();
Copy link
Member

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.

Copy link
Contributor Author

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.
@jtbandes
Copy link
Contributor Author

@swift-ci please smoke test

@DougGregor
Copy link
Member

LGTM now, thanks!

@DougGregor DougGregor merged commit 0283be9 into swiftlang:master Sep 22, 2016
@jtbandes jtbandes deleted the diag-fixity branch September 22, 2016 06:24
kateinoigakukun added a commit that referenced this pull request Aug 31, 2022
[pull] swiftwasm from main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants