Lyricdev
GitHub

LYR-SEM0084

'throws' on a type that is no coroutine or task

error ยท spec 10-concurrency

A type written T throws E where T is neither a coroutine nor a task type.

Explanation

throws after a type says what a coroutine's pulls or a task's body may end with. Anything else runs at its call, and a function says what it throws in its own signature; on a plain value that never runs anything the clause has no meaning.

Remove the throws from the type, and declare it on the function that throws.

Wrong

fn main(): void {
    let n: int throws Error = 1;
    let _ = n;
}
fn main(): void {
    let n: int = 1;
    let _ = n;
}