XO0205: `?` where the enclosing function cannot return the failure
? on a Result needs a function or closure that can fail, and ? on an optional needs one that returns an optional. A function without ! cannot propagate an error, and a requires ... else clause in such a function has nowhere to return its error either. Declare the error type (the diagnostic offers ! E as a fix), or handle the failure with match, ??, or ignore_err. See core 2.5 and 2.6. Coming from Go: knowledgebase/guides/option-result-for-go.md maps if err != nil, v, ok := m[k], error wrapping, and errors.Is to Xo (https://github.com/xo-lang/xo/blob/main/knowledgebase/guides/option-result-for-go.md).
Example
enum E { A }
fn g() -> Int ! E { 1 }
fn f() -> Int { g()? }Fix
enum E { A }
fn g() -> Int ! E { 1 }
fn f() -> Int ! E { g()? }Run xo explain XO0205 for this text in a terminal, or see
section 10.6 of the specification.