-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Parser] Improve diagnostics for special platforms in available attribute. #18895
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
Conversation
@swift-ci please test |
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.
Thanks for picking this up!
@@ -1316,6 +1316,20 @@ ERROR(attr_availability_expected_equal,none, | |||
ERROR(attr_availability_expected_version,none, | |||
"expected version number in '%0' attribute", (StringRef)) | |||
|
|||
WARNING(attr_availability_swift_platform_expected_option,none, | |||
"expected '%0' option with a version number for swift platform, " |
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.
Nitpick: I suggest using this as "platform 'swift'" (like "platform '*'"). It seems a little clearer to me.
After seeing it in context, I also think it might just be better to simplify to something like "expected 'introduced', 'deprecated', or 'obsoleted' in '%0' attribute for platform 'swift'". It does mean we have to keep it up to date, but it's less circumlocution.
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.
Fixed
"expected '%0' option with a version number for swift platform, " | ||
"such as 'introduced', 'deprecated', or 'obsoleted'", (StringRef)) | ||
WARNING(attr_availability_swift_platform_deprecated,none, | ||
"'deprecated' must have a version number for swift platform in '%0' " |
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.
This could also apply to obsoleted
or introduced
, right?
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, obsoleted
and introduced
must always have a version number alongside, while version for deprecated
is optional. In this particular case (i.e., platform 'swift'), however, deprecated
cannot be used alone and must followed by a version. So, the motivation of such warning here is for deprecated
only.
"'deprecated' must have a version number for swift platform in '%0' " | ||
"attribute", (StringRef)) | ||
WARNING(attr_availability_swift_platform_infeasible,none, | ||
"argument '%0' is infeasible for swift platform in '%1' attribute", |
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.
Nitpick: To match the tone of other diagnostics, I would prefer something more like "cannot be used with" instead of "is infeasible for". (I'm also not sure we call them "arguments" in attributes, but in this case I think just leading with '%0'
is fine.)
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.
Done
lib/Parse/ParseDecl.cpp
Outdated
@@ -528,6 +547,14 @@ ParserResult<AvailableAttr> Parser::parseExtendedAvailabilitySpecList( | |||
return nullptr; | |||
} | |||
|
|||
// Warn if any version is specified for non-specific '*' platforms. | |||
if (Platform == "*" && SomeVersion) { | |||
diagnose(AttrLoc, |
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.
Is it possible to add a fix-it for this one?
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.
Good idea! Fix-it added.
Thanks for the review, Jordan! I updated the code to address your comments. |
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.
Thanks, this looks great!
@swift-ci Please test |
Build failed |
Build failed |
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.
Looks great! thank you!
Oh, just noticed some warnings are raised from |
I updated the code to fix the warnings in In addition, I checked other projects and found corelibs-libdispatch affected. I created #391 there. |
Whoops. Thank you for checking. cc @airspeedswift |
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.
LGTM. Thanks!
@swift-ci please test |
Let's wait for the SCD changes before merging. |
…bute. This patch adds warnings when a version number is used on the non-specific '*' platform. In addition, it fixes some misleading warning messages on 'swift' platform. Resolves: SR-8598.
Hi Jordan, thank you for taking care of the dependency PR #391 in swift-corelibs-libdispatch repo. I just updated the code here to make sure it is conflict-free. |
Let's do it! @swift-ci Please test |
swiftlang/swift#18895. Signed-off-by: Kim Topley <[email protected]>
This patch adds warnings when a version number is used on the non-specific
*
platform. For example, it warns unexpected version number in 'available' attribute for non-specific platform '*' in the following case:In addition, it fixes some misleading warning messages on
swift
platform as mentioned by @airspeedswift , including the following cases:Resolves SR-8598.