-
Notifications
You must be signed in to change notification settings - Fork 10.5k
SR-13976: Improve compiler error message: "partial application of ‘mutating’ method is not allowed" #35466
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
SR-13976: Improve compiler error message: "partial application of ‘mutating’ method is not allowed" #35466
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,31 +6,31 @@ struct Foo { | |
mutating func boom() {} | ||
} | ||
|
||
let x = Foo.boom // expected-warning{{partial application of 'mutating' method}} | ||
let x = Foo.boom // expected-warning{{cannot reference 'mutating' method as function value; calling the function has undefined behavior and will be an error in future Swift versions}} | ||
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 am not sure why this test was working on main before? the warnings for swift 4 should have always had the second clause. But alas, run the tests locally and fixed the CI issues |
||
var y = Foo() | ||
let z0 = y.boom // expected-error{{partial application of 'mutating' method}} | ||
let z1 = Foo.boom(&y) // expected-error{{partial application of 'mutating' method}} | ||
let z0 = y.boom // expected-error{{cannot reference 'mutating' method as function value}} | ||
let z1 = Foo.boom(&y) // expected-error{{cannot reference 'mutating' method as function value}} | ||
|
||
func fromLocalContext() -> (inout Foo) -> () -> () { | ||
return Foo.boom // expected-warning{{partial application of 'mutating' method}} | ||
return Foo.boom // expected-warning{{cannot reference 'mutating' method as function value; calling the function has undefined behavior and will be an error in future Swift versions}} | ||
} | ||
func fromLocalContext2(x: inout Foo, y: Bool) -> () -> () { | ||
if y { | ||
return x.boom // expected-error{{partial application of 'mutating' method}} | ||
return x.boom // expected-error{{cannot reference 'mutating' method as function value}} | ||
} else { | ||
return Foo.boom(&x) // expected-error{{partial application of 'mutating' method}} | ||
return Foo.boom(&x) // expected-error{{cannot reference 'mutating' method as function value}} | ||
} | ||
} | ||
|
||
func bar() -> P.Type { fatalError() } | ||
func bar() -> Foo.Type { fatalError() } | ||
|
||
_ = bar().boom // expected-warning{{partial application of 'mutating' method}} | ||
_ = bar().boom(&y) // expected-error{{partial application of 'mutating' method}} | ||
_ = bar().boom(&y)() // expected-error{{partial application of 'mutating' method}} | ||
_ = bar().boom // expected-warning{{cannot reference 'mutating' method as function value; calling the function has undefined behavior and will be an error in future Swift versions}} | ||
_ = bar().boom(&y) // expected-error{{cannot reference 'mutating' method as function value}} | ||
_ = bar().boom(&y)() // expected-error{{cannot reference 'mutating' method as function value}} | ||
|
||
func foo(_ foo: Foo.Type) { | ||
_ = foo.boom // expected-warning{{partial application of 'mutating' method}} | ||
_ = foo.boom(&y) // expected-error{{partial application of 'mutating' method}} | ||
_ = foo.boom(&y)() // expected-error{{partial application of 'mutating' method}} | ||
_ = foo.boom // expected-warning{{cannot reference 'mutating' method as function value; calling the function has undefined behavior and will be an error in future Swift versions}} | ||
_ = foo.boom(&y) // expected-error{{cannot reference 'mutating' method as function value}} | ||
_ = foo.boom(&y)() // expected-error{{cannot reference 'mutating' method as function value}} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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 cannot build swift locally at the moment, while I fix that so I can run the test suite locally. Does the second clause here make sense? "cannot reference x as function value calling the function has undefined..."
I think so since is error/warning will be in the context of a function I believe
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.
Yes, I think it makes sense, second part is a clarification on why it can't be used as a function value - because calling it is UB.