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-9618] An initializer that delegates to a failable initializer has no way to check if the inner call failed. #52064

Open
swift-ci opened this issue Jan 8, 2019 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself feature A feature request or implementation

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Jan 8, 2019

Previous ID SR-9618
Radar None
Original Reporter CTMacUser (JIRA User)
Type Bug
Additional Detail from JIRA
Votes 3
Component/s Compiler
Labels Bug, LanguageFeatureRequest
Assignee None
Priority Medium

md5: 3647163ac6c28a30a45a7be03b2abb49

Issue Description:

As I understand it, there are two ways for an initializer that delegates to a failable initializer to react to the delegated initializer failing.

  1. If the delegating initializer is nonfailable, then it must call the other initializer with a trailing "!" to cause a crash if it fails.

  2. If the delegating initializer can fail, it can call the other initializer without any suffix and the system will make sure the outer initializer will pass on the inner's fail-ness if that occurs.

There doesn't seem to be a way for the outer initializer to test that the inner one failed and carry out some other policy, like throwing an error. I don't know if there's any other solutions beside throwing an error. (You could re-evaluate another value with another initializer call, but we may want to limit the number of delegated initializer calls to one.)

There's more information at a thread I created before this.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 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 feature A feature request or implementation
Projects
None yet
Development

No branches or pull requests

1 participant