Error codes

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

In a terminal: auk explain E0248 prints this page.

On this page

The function returns an optional T?, which can say "missing" but can't carry an error. ? on a T! would lose the error, so Auk asks you to decide explicitly.

Wrong#

auk
fn parse(s: str): int? {
  let n = int.parse(s)?
  n
}

Fixed#

auk
fn parse(s: str): int? {
  let n = int.parse(s) else { return none }
  n
}

Common causes#

  • Mixing fallible (T!) and optional (T?) calls in one function: pick one return type.
  • If callers need the reason, return T! instead.

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