Lyricdev
GitHub

LYR-SEM0038

a bare yield in a coroutine that yields values

error ยท spec 10-concurrency

A yield; without a value stands in a coroutine whose yield type is not void.

Explanation

A coroutine Coroutine<Y> hands a Y to its caller at every yield. A bare yield; hands nothing and belongs to a Coroutine<void>, which only suspends.

Yield a value of the coroutine's type, or declare the coroutine Coroutine<void>.

Wrong

fn gen(): Coroutine<int> {
    yield;
}

fn main(): void {
    let c = gen();
    let _ = c.next();
}
fn gen(): Coroutine<int> {
    yield 1;
}

fn main(): void {
    let c = gen();
    let _ = c.next();
}