Alc
(Alc)
1
I am on Swift 5.10 and I use swift -enable-upcoming-feature FullTypedThrows myFile.swift to compile, but I get the following error messages.
myFile.swift:6:22: error: consecutive statements on a line must be separated by ';'
func callCat() throws(CatError) {
^
;
myFile.swift:6:6: error: expected '{' in body of function declaration
func callCat() throws(CatError) {
^
myFile.swift:6:22: error: 'CatError' cannot be constructed because it has no accessible initializers
func callCat() throws(CatError) {
^~~~~~~~~~
myFile.swift:7:12: error: type 'any Error' has no member 'sleeps'
throw .sleeps
~^~~~~~
Code I used.
enum CatError: Error {
case sleeps
case sitsAtATree
}
func callCat() throws(CatError) {
throw .sleeps
}
Can anyone tell me what I am doing wrong? This is the first time I am trying to use -enable-upcoming-feature so maybe I am misunderstanding its use or maybe my code and understanding of the feature itself is wrong 
PS: I came here from [Accepted] SE-0413: Typed throws - #21 by xwu
this proposal is accepted. You can try it out for yourself
As far as I can see from the source code, it got demoted to an experimental feature for the time being and is only available from Swift 6 on. In other words, the option is -enable-experimental-feature FullTypedThrows and a Swift 6 nightly is required.
1 Like
It doesn't require a nightly build, it's available in the official Swift 6 builds too (e.g. Xcode 16 betas).
However, FullTypedThrows isn't ready yet. It frequently causes compiler hangs, for example.
See the earlier thread, Where is FullTypedThrows?.
Note in particular @hborla's comment that it's not really meant to be used yet, as it's known to be both functionally incomplete and buggy (my elaboration, not hers, but I believe that's accurate).
3 Likes