Error codes

E0243: ? in a function that doesn't return T! or T?

In a terminal: auk explain E0243 prints this page.

On this page

? passes an error or a missing value up to the caller, so the function itself must return T! or T?. Otherwise handle the failure here with else or match.

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 0
  n
}

Common causes#

  • Forgetting the ! in the return type: fn parse(s: str): int!.
  • fn main() without a return type: write fn main(): ()! to let errors reach the top.
  • ? inside a closure passed to map: the closure's own return type matters.

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