Skip to content
ZOLO / TE834 Type · error

nil-only operator used directly on boxed `Option`/`Result`

Compiler diagnostic TE834: nil-only operator used directly on boxed `Option`/`Result`.

Why this fires

?. and ?? are nil-only operators. Option<T> and Result<T, E> are boxed enum values, so neither wrapper is itself nil and ?? cannot unwrap it.

fn maybe() -> Option<int> { Option.None }

fn invalid() -> int {
    maybe() ?? 7 // error[TE834]
}

Fix it

Use postfix ? to propagate, pattern matching to handle both variants, or an explicit wrapper operation such as unwrap_or when a default is intended:

fn valid() -> int {
    Option.unwrap_or(maybe(), 7)
}

Reserve ?? for a genuine T? value whose empty representation is runtime nil.

See also

  • TE832 — postfix propagation needs a fallible operand.
  • TE833 — the propagated failure does not match the return type.

Global index

Find your way through Zolo

Try an idea

Start here

9 results

9 results

en