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-9421] Passing an optional throwing block from one rethrowing func to another fails #51885

Closed
ffried opened this issue Dec 6, 2018 · 3 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis

Comments

@ffried
Copy link
Contributor

ffried commented Dec 6, 2018

Previous ID SR-9421
Radar None
Original Reporter @ffried
Type Bug
Status Closed
Resolution Done
Environment

macOS:

Apple Swift version 4.2.1 (swiftlang-1000.11.42 clang-1000.11.45.1)
Target: x86_64-apple-darwin18.2.0

Ubuntu 16.04:

Swift version 4.2.1 (swift-4.2.1-RELEASE)
Target: x86_64-unknown-linux-gnu
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, Miscompile, TypeChecker
Assignee None
Priority Medium

md5: b8ba5cd1ae2e1a2e51c8feb8b80543a2

relates to:

  • SR-5427 Crash in generated code when calling optional closure that throws

Issue Description:

The following code produces a crashing binary on macOS and fails to compile on Linux:

func sr5427_base(op: (() throws -> Void)?) rethrows { try op?() }
func sr5427_wrapper(op: (() throws -> Void)?) rethrows { sr5427_base(op: op) }
struct SR5427: Error {}
try? sr5427_wrapper(op: { throw SR5427() })

The issue is likely similar to SR-5427, with the difference that the optional throwing block is passed on to another function.

@belkadan
Copy link
Contributor

belkadan commented Dec 6, 2018

@rudkx, you just fixed something like this, right?

@rudkx
Copy link
Member

rudkx commented Dec 6, 2018

I fixed something related. With master you'll now get the following, and after adding the try it appears to compile and execute without error.

/tmp/sr9421.swift:2:58: error: call can throw but is not marked with 'try'
func sr5427_wrapper(op: (() throws -> Void)?) rethrows { sr5427_base(op: op) }
^~~~~~~~~~~~~~~~~~~
/tmp/sr9421.swift:2:74: note: call is to 'rethrows' function, but argument function can throw
func sr5427_wrapper(op: (() throws -> Void)?) rethrows { sr5427_base(op: op) }

@ffried
Copy link
Contributor Author

ffried commented Mar 26, 2019

I can confirm that this is fixed in Swift 5 (Xcode 10.2)

@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 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants