-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1735,7 +1735,10 @@ 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", ()) | ||
"%0 modifier cannot be used on static functions", | ||
(SelfAccessKind)) | ||
NOTE(static_functions_not_mutating_detail,none, | ||
"static members cannot access instance properties or self", ()) | ||
Comment on lines
+1740
to
+1741
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I’m not a fan of this interpretation because it’s misleading. We have this very problem with another diagnostic: #62909. You can access both Maybe we could borrow a more clear phrasing from the book. For example:
|
||
|
||
ERROR(readwriter_mutatingness_differs_from_reader_or_writer_mutatingness,none, | ||
"%0 cannot be %1 when " | ||
|
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.
If you incorporate the declaration like so, the message will be also be tailored for an accessor:
We loose the plural, but I think that’s fine because the object remains indefinite.