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
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself good first issue Good for newcomers type checker Area → compiler: Semantic analysis

Comments

@hamishknight
Copy link
Collaborator

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

Was something supposed to be generic here?

@hamishknight
Copy link
Collaborator Author

@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

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

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

@belkadan
Copy link
Contributor

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

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 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
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself good first issue Good for newcomers type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

4 participants