Error codes

E0249: ? on T? in a function returning T!

In a terminal: auk explain E0249 prints this page.

On this page

The function returns T!, so ? must produce an error, but a missing optional value carries no error message. Say what the error is with else fail("...").

Wrong#

auk
fn head(xs: [int]): int! {
  let x = xs.first()?
  x
}

Fixed#

auk
fn head(xs: [int]): int! {
  let x = xs.first() else fail("empty list")
  x
}

Common causes#

  • find, get, first, env.get return T?: give the missing case a message.
  • Return T? from the function instead if "missing" is all callers need.

Stuck on a word? Try the glossary. Got a compiler error? Look up its code. Improve this page