-
Notifications
You must be signed in to change notification settings - Fork 241
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
[Swift] Would it be possible to use checked exceptions? #2179
Comments
Could you please say a bit more about what you mean by “using checked exceptions”? 😊 UniFFI does generate throwing Swift functions for methods and functions that are annotated with You can see an example of this in Maybe I’m misunderstanding what you’re asking, though? Please let us know! |
Hey @linabutler , what I meant is the the swift bindings that throw errors are not using checked exception notations which are supported by the language. E.g.: This rust function
Is translated into:
What I would like to see:
I was wondering if there is currently anything preventing anyone from adding this to the generated bindings? |
Ahh, I'm so sorry, I didn't realize you were talking about typed throws!
I did some digging, and it looks like typed throws aren't actually shipping in any Swift release just yet! The documentation page you linked to is a little ahead of the game 😅 The latest release of Swift is 5.10.1, but SE-0413 is only available in the Swift 6 development snapshots.
Digging a bit more, swiftlang/swift#74449 says:
...So they might not be ready for the Swift 6 release, and it'll be a while before we can adopt them in the UniFFI bindings. |
Oh, sorry about that, I did not realize that this was not properly supported in the current version of swift. Thanks for you time. |
@linabutler Hey! I might do a UniFFI PR later this fall when Xcode 16 GM is released - and with it Swift 6 - in which we can add a new config to We can simply use #if swift(>=6.0)
func frobnicate throws (MyError) { ... }
#else
func frobnicate throws { ... }
#endif To support UniFFI consumers pre and post Swift 6.0. I think that should work. What do you think? (where |
Sounds great to me, @Sajjon—thank you! 🏆 |
Is there any blocker currently that prevents uniffi from using checked exception in the generated binding code for swift?
The text was updated successfully, but these errors were encountered: