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-10651] Currying from a non-throwing function to a throwing function causes a runtime crash if an error is attempted to be rethrown. #53051

Open
bscothern opened this issue May 9, 2019 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software run-time crash Bug → crash: Swift code crashed during execution

Comments

@bscothern
Copy link

Previous ID SR-10651
Radar rdar://problem/50664921
Original Reporter @bscothern
Type Bug

Attachment: Download

Environment

macOS 10.14.4

Xcode 10.2.1

Apple Swift version 5.0.1 (swiftlang-1001.0.82.4 clang-1001.0.46.5)

Target: x86_64-apple-darwin18.5.0

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, RunTimeCrash
Assignee None
Priority Medium

md5: bd84e8be4e656015acc925eb790f6af1

Issue Description:

If a function takes a function that is curried into a throwing function, the outer functions rethrows is ignored and causes a runtime crash for not handling the error.

This can be duplicated by running the attached main.swift file.

The example of this is found with the use of forEachApply3 when calling A.thrower``.

@belkadan
Copy link
Contributor

Hm. I don't think the throws is intended to count for rethrows in any position but the top-level one. That's not what you want, but it's probably the only thing we can implement.

@bscothern
Copy link
Author

I can understand that limitation from a design perspective. I've continued to try and find a way around it but have had no luck.

Would it be possible to add a warning or compilation error when you call a throwing function other than the top-level one and don't handle its error? Looking at my code I imagine that would be quite difficult to detect though. Hmmm...

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
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 crash Bug: A crash, i.e., an abnormal termination of software run-time crash Bug → crash: Swift code crashed during execution
Projects
None yet
Development

No branches or pull requests

3 participants