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