LYR-PAR0049
several types not in brackets, or an empty type list
Several types follow throws, or a catch binding's : or in, without brackets around them; or a bracketed list after throws, catch (e in …) or a pattern's in is empty.
Explanation
One type stands bare, several stand in brackets — the list rule: throws E, throws [A, B], catch (e in [A, B]). An empty list names nothing: the bare throws already means Error, catch (e) already takes everything, and _ already matches everything.
Put the types in brackets, or write the bare form.
Wrong
enum A :: [Error] { X; fn message(): string { return "a"; } }
enum B :: [Error] { Y; fn message(): string { return "b"; } }
fn f(): int throws A, B {
return 1;
}
fn main(): void {
}
Right
enum A :: [Error] { X; fn message(): string { return "a"; } }
enum B :: [Error] { Y; fn message(): string { return "b"; } }
fn f(): int throws [A, B] {
return 1;
}
fn main(): void {
let _ = try? f();
}