Skip to content
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

[Sema] Look through FunctionConversionExpr when finding @discardableResult callee #60324

Merged

Conversation

theblixguy
Copy link
Collaborator

@theblixguy theblixguy commented Jul 31, 2022

Resolves #60276

@discardableResult @MainActor
func a() async -> Int { 5 }

func b() async {
  await a()
}

On 5.7. you get a warning:

<source>:3:11: warning: result of call to function returning 'Int' is unused
    await a()
          ^~~

When using @MainActor the call is wrapped in an implicit FunctionConversionExpr and we currently do not look through that to find the callee function, so the code falls through and triggers this warning.

This is a regression in 5.7, as this warning does not appear in 5.6.

@theblixguy theblixguy requested a review from xedin July 31, 2022 17:35
@theblixguy theblixguy self-assigned this Jul 31, 2022
@xedin
Copy link
Contributor

xedin commented Aug 1, 2022

@swift-ci please test

@LucianoPAlmeida
Copy link
Contributor

MacOS test is failing on OSes that not support concurrency, I think in this case is just fine to run this with -disable-availability-checking at RUN line...

@theblixguy theblixguy force-pushed the discardable-result-look-through-func-conv branch from 3a8ce71 to c5c344c Compare August 1, 2022 16:03
@theblixguy
Copy link
Collaborator Author

@swift-ci please test

@theblixguy theblixguy force-pushed the discardable-result-look-through-func-conv branch from c5c344c to f5148a9 Compare August 1, 2022 17:33
@theblixguy
Copy link
Collaborator Author

@swift-ci please test

@theblixguy
Copy link
Collaborator Author

BTW should I create a 5.7 PR too? Since it’s a regression and it’s a very low risk change.

@xedin xedin merged commit f106b4e into swiftlang:main Aug 2, 2022
@theblixguy theblixguy deleted the discardable-result-look-through-func-conv branch August 2, 2022 05:42
@xedin
Copy link
Contributor

xedin commented Aug 3, 2022

@theblixguy Please do open 5.7 PR for this.

@flowtoolz
Copy link

flowtoolz commented Sep 16, 2022

It has been merged on August 4, but the bug is still present in the official Xcode 14 release. May I be doing anything wrong?

Screenshot 2022-09-16 at 12 06 08

Edit: Ooops, I see this has already been discussed in #60386.

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.

Getting "unused" warning from function annotated with "@discardableResult"
4 participants