-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fix the static_functions_not_mutating error messsage #78052
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
base: main
Are you sure you want to change the base?
Conversation
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.
Thank you for the contribution! I left a comment inline about the text and as a separate note: please modify existing tests (because the text is now different) or make sure that we have tests for both nonmutating
and mutating
attributes that exercise the new diagnostics before we can run CI and land this.
@@ -1718,7 +1718,7 @@ ERROR(functions_mutating_and_not,none, | |||
"method must not be declared both %0 and %1", | |||
(SelfAccessKind, SelfAccessKind)) | |||
ERROR(static_functions_not_mutating,none, | |||
"static functions must not be declared mutating", ()) | |||
"nonmutating or mutating modifiers cannot be used on static functions because they do not operate on instance properties or self", ()) |
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.
Instead of clamping mutating and nonmutating together it would be better to print one or the other depending on what the attribute was, a boolean flag could be used to distinguish between the two (i.e. no_overloads_match_exactly_in_call
does a similar thing reference vs. call).
Instead of "operate" we can use "cannot access" and the "because" part can be turned into a note.
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.
@xedin
Thanks for the advice!
I fixed based on your suggestion.
d0d9099
to
cb96921
Compare
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.
I left one more small note inline. We also have a few tests that use the diagnostic and they'd need to be adjusted before we can land this:
test/Sema/immutability.swift:134
test/decl/subscript/static.swift:23
test/decl/subscript/static.swift:24
test/decl/overload.swift:413
@felixinkinto Next time, please ask us to assign you to an issue before you start working on one. A good first issue is a queue, not a race. We want to avoid instances of multiple people independently working on them. |
cb96921
to
e8b9b8c
Compare
@xedin sorry for the delay for long. I addressed the feedback. May I ask some questions to do behaviour checks?
|
@AnthonyLatsis |
@swift-ci please test Windows platform |
Fix #77835