OxL Reference

error yield-outside-stream

error Standard: [§10.3]

What it means#

A generator is a function whose result type is stream<T, E> and whose body contains yield (§10.3). yield x hands the element x (a T) to the consumer of the stream and suspends the body until the consumer asks for the next one. Anywhere else — in an ordinary function, in a lambda inside a generator (a lambda is a different function), or in a function whose result is not a stream — there is no stream to yield to.

Example#

oxl✓ checked in CI
fn plain() -> i32 {
  yield 1       // <- yield-outside-stream
  2
}
error
yield-outside-stream

How to fix#

Declare the function as a generator, or return the value:

oxl✓ checked in CI
fn numbers() -> stream<i32> {
  yield 1
  yield 2
}

See also#

OxL 1.0.0-beta · Documentation version 1.0.0-beta© OxwaldLink · generated from the Standard, the std sources and the guides