-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SR-4231] Add diagnostic (& fix-it) for mixed syntax availability attribute #9122
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
Changes from all commits
73ff1c5
71fac57
bb16afc
336022a
c54dce0
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// RUN: %target-typecheck-verify-swift | ||
|
||
// SR-4231: Misleading/wrong error message for malformed @available | ||
|
||
@available(OSX 10.6, *) // no error | ||
func availableSince10_6() {} | ||
|
||
@available(OSX, introduced: 10.0, deprecated: 10.12) // no error | ||
func introducedFollowedByDeprecated() {} | ||
|
||
@available(OSX 10.0, deprecated: 10.12) | ||
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. For visibility (got folded by the force-pushes): Can you make this recover? There's a decl down there, but this second diagnostic makes it seems like there isn't. 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 think that it probably could be made to recover, but I don't know how to do it. (I’m assuming that recovery means being able to emit the right attribute and continue parsing.) As far as I understand how this works I think that in order to recover, it would need to pass some additional information back so that an Not that it would be a lot of work, but I don’t know if it would add much on top of the diagnostic and fix-it. That said; if you think it's worth doing, I would see it as a good learning opportunity. 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. Recovery could be as simple as re-forming the attribute list as though the user had accepted your fixit, then just sending things on downstream. It's not a pressing thing and could definitely be addressed in another pull request. |
||
// expected-error@-1 {{'deprecated' can't be combined with shorthand specification 'OSX 10.0'}} | ||
// expected-note@-2 {{did you mean to use 'OSX, introduced: 10.0'?}} {{15-15=, introduced:}} | ||
// expected-error@-3 {{expected declaration}} | ||
func shorthandFollowedByDeprecated() {} | ||
|
||
@available(OSX 10.0, introduced: 10.12) | ||
// expected-error@-1 {{'introduced' can't be combined with shorthand specification 'OSX 10.0'}} | ||
// expected-error@-2 {{expected declaration}} | ||
func shorthandFollowedByIntroduced() {} | ||
|
||
@available(iOS 6.0, OSX 10.8, *) // no error | ||
func availableOnMultiplePlatforms() {} | ||
|
||
@available(iOS 6.0, OSX 10.0, deprecated: 10.12) | ||
// expected-error@-1 {{'deprecated' can't be combined with shorthand specification 'OSX 10.0'}} | ||
// expected-error@-2 {{expected declaration}} | ||
func twoShorthandsFollowedByDeprecated() {} |
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.
In general, can you run git-clang-format on this patch. There's like 4 or 5 places with some interesting indentation.