Skip to content

[SR-1052][Parser] Warning + FixIt for @warn_unused_result #2760

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 1 commit into from
Jun 8, 2016

Conversation

tanadeau
Copy link
Contributor

What's in this pull request?

Part 6 (final part) of SR-1052: Support for the now-useless @warn_unused_result is removed with an error and fixit.

Resolved bug number: (SR-1052)


Before merging this pull request to apple/swift repository:

  • Test pull request on Swift continuous integration.

Triggering Swift CI

The swift-ci is triggered by writing a comment on this PR addressed to the GitHub user @swift-ci. Different tests will run depending on the specific comment that you use. The currently available comments are:

Smoke Testing

Platform Comment
All supported platforms @swift-ci Please smoke test
All supported platforms @swift-ci Please smoke test and merge
OS X platform @swift-ci Please smoke test OS X platform
Linux platform @swift-ci Please smoke test Linux platform

Validation Testing

Platform Comment
All supported platforms @swift-ci Please test
All supported platforms @swift-ci Please test and merge
OS X platform @swift-ci Please test OS X platform
OS X platform @swift-ci Please benchmark
Linux platform @swift-ci Please test Linux platform

Lint Testing

Language Comment
Python @swift-ci Please Python lint

Note: Only members of the Apple organization can trigger swift-ci.

@tanadeau
Copy link
Contributor Author

tanadeau commented Jun 3, 2016

I rebased and fixed the conflicts.

@gribozavr
Copy link
Contributor

CC @DougGregor @jopamer @jrose-apple

@tanadeau If you could submit test changes Removed last uses of @warn_unused_result as a separate PR, I'd merge them right away.

@tanadeau
Copy link
Contributor Author

tanadeau commented Jun 6, 2016

@gribozavr I'm in the process of rebasing and retesting now.

Do you want me to split that commit off into another PR because it's big enough to be its own PR or because it's the commit tending to cause conflicts? If it's the latter, it won't help as the problematic file is for the newly introduced fixit to remove @warn_unused_result which is tied to the rest of this PR.

@tanadeau tanadeau force-pushed the sr-1052-remove-old-attr branch from 600c6e9 to be5e811 Compare June 6, 2016 12:14
@tanadeau
Copy link
Contributor Author

tanadeau commented Jun 6, 2016

Rebased.

@gribozavr
Copy link
Contributor

@tanadeau Because we can land those changes and stop worrying about them, while making the patch smaller to review.

"expected a string following ':' for '%0' parameter", (StringRef))
WARNING(attr_warn_unused_result_unknown_parameter,none,
"unknown parameter '%0' in 'warn_unused_result' attribute", (StringRef))
ERROR(attr_warn_unused_result_removed,none,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a warning rather than an error for now, so that people can update their code at their leisure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made it an error as that was what @lattner put in the JIRA ticket. I can change that if still desired though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think any diagnostic that says "x has no effect and the right fix is to remove it" should be a warning rather than an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense to me. I based it off the ticket, and an error seemed to follow the pattern for "renamed" attributes since there were not already any that were completely removed. I'll make that change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Diagnostic changed to warning.

@jrose-apple
Copy link
Contributor

Other than those two comments the compiler changes look good to me.

@tanadeau
Copy link
Contributor Author

tanadeau commented Jun 6, 2016

@gribozavr I split out the commit you requested into a new PR (#2923).

@tanadeau tanadeau force-pushed the sr-1052-remove-old-attr branch from be5e811 to 3324b81 Compare June 7, 2016 02:12
@tanadeau
Copy link
Contributor Author

tanadeau commented Jun 7, 2016

I rebased against latest master (including merge of #2923). This PR is now much smaller.

@tanadeau tanadeau force-pushed the sr-1052-remove-old-attr branch from 3324b81 to f0c65dc Compare June 8, 2016 01:57
@tanadeau tanadeau changed the title [SR-1052][Parser] Error + FixIt for @warn_unused_result [SR-1052][Parser] Warning + FixIt for @warn_unused_result Jun 8, 2016
@tanadeau
Copy link
Contributor Author

tanadeau commented Jun 8, 2016

I believe I've addressed all of the comments. I changed the name of the PR since the diagnostic is now a warning instead of an error.

@jrose-apple
Copy link
Contributor

Thanks, Trent! Let's do one last CI build.

@swift-ci Please test

@tanadeau
Copy link
Contributor Author

tanadeau commented Jun 8, 2016

The Linux test failure appears to be unrelated to this PR.

@jrose-apple
Copy link
Contributor

Yep, I'm willing to call this good enough. Merging!

@jrose-apple jrose-apple merged commit 78a420d into swiftlang:master Jun 8, 2016
@tanadeau tanadeau deleted the sr-1052-remove-old-attr branch June 8, 2016 17:11
@tanadeau
Copy link
Contributor Author

tanadeau commented Jun 8, 2016

Thanks!

@gribozavr
Copy link
Contributor

@tanadeau I'm afraid there's an issue:

import Foundation
class X {
  @warn_unused_result
  @objc
  func foo() -> Int {}
}
$ xcrun $(pwd)/bin/swiftc b.swift
b.swift:3:3: warning: 'warn_unused_result' attribute behavior is now the default
  @warn_unused_result
  ^~~~~~~~~~~~~~~~~~~

b.swift:4:3: error: expected declaration
  @objc

Why does it produce an error?

@tanadeau
Copy link
Contributor Author

tanadeau commented Jun 9, 2016

@gribozavr, I think I have a fix for that issue. The return value in my if is not correct. It just mattered that I was returning early if there were no other attributes. I'm going to have a PR shortly.

@tanadeau
Copy link
Contributor Author

tanadeau commented Jun 9, 2016

@gribozavr I created #2970 with the fix and a new test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants