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

[SR-7297] Discarding a function from a discardableResult method causes a compiler error #49845

Closed
hamishknight opened this issue Mar 28, 2018 · 7 comments

Comments

@hamishknight
Copy link
Collaborator

@hamishknight hamishknight commented Mar 28, 2018

Previous ID SR-7297
Radar None
Original Reporter @hamishknight
Type Bug
Status Closed
Resolution Duplicate
Environment

Swift version 4.2-dev (LLVM 95345677bd, Clang daefc772c1, Swift 76c264e)
Target: x86_64-apple-darwin17.4.0

Additional Detail from JIRA
Votes 3
Component/s Compiler
Labels Bug, StarterBug, TypeChecker
Assignee mininny (JIRA)
Priority Medium

md5: e13cd5b57c6ed6e6ebdcd72597f0a419

duplicates:

  • SR-12271 @discardableResult not working for static function with function return type

relates to:

Issue Description:

This example doesn't compile:

struct S {
  @discardableResult
  func foo() -> () -> String { fatalError() }
}

let s = S()
s.foo() // error: Expression resolves to an unused function

But really it should. Interestingly enough it does compile if it's a top-level function:

@discardableResult
func foo() -> () -> String { fatalError() }

foo()
@belkadan
Copy link
Contributor

@belkadan belkadan commented Mar 28, 2018

Was something supposed to be generic here?

@hamishknight
Copy link
Collaborator Author

@hamishknight hamishknight commented Mar 28, 2018

@belkadan No, sorry, originally I thought the function being generic was the issue, but turns out it's just due to it being a method vs a top-level function.

@belkadan
Copy link
Contributor

@belkadan belkadan commented Mar 29, 2018

The original was a StarterBug, so I bet this one is simple enough too. (I see the oversight in Erik's patch now!)

@hamishknight
Copy link
Collaborator Author

@hamishknight hamishknight commented Apr 2, 2018

chuganzy (JIRA User) has opened a PR here: #15675

@belkadan
Copy link
Contributor

@belkadan belkadan commented Jul 27, 2019

Resetting assignee on all Starter Bugs not modified since 2018. If someone wants to pick up chuganzy (JIRA User)'s work that would be great!

@swift-ci
Copy link
Collaborator

@swift-ci swift-ci commented Dec 27, 2020

Comment by Minhyuk Kim (JIRA)

This issue seems to duplicated here: https://bugs.swift.org/browse/SR-12271 and fixed here: #30077

@xwu
Copy link
Collaborator

@xwu xwu commented Mar 21, 2021

Indeed, this is now fixed. mininny (JIRA User) OK to mark as resolved? @hamishknight OK to close?

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants