Skip to content
ZOLO / TE221 Type · error

yield used outside a generator

`yield` is only valid inside a generator declared with `fn*`. An ordinary or `async fn` produces a single result and exposes no pull iterator to yield into.

Why this fires

yield is only valid in a generator declared with fn*. An ordinary or async fn returns one result; it does not expose a pull iterator.

fn values() { yield 1 } // TE221

Fix it

Use fn* when the function is intended to produce a sequence:

fn* values() -> int {
    yield 1
}

Calling this function returns Iter<int>. If only one value is needed, replace yield value with the function's ordinary return or tail value.

Global index

Find your way through Zolo

Try an idea

Start here

9 results

9 results

enespt-br