Result Handling Cookbook
This subsection is the canonical v0.33.6 guide for Nitpick's
Result<T> handling surface. It supersedes older scattered notes in
guide/types/result.md, guide/functions/result_system.md, and
guide/operators/result_operators.md where those pages disagree with the
v0.33.x audits.
The v0.33.x cycle locked the shipped behavior of every Result-family
operator and keyword: pass, fail, ?, ??, ?!, ?|, defaults,
drop, raw, _?, _!, safe navigation, and contextual catch.
Chapters
- Cheatsheet — one-page table for every Result, Optional/null, shorthand, and contextual handler surface.
- Pass and fail — implicit
Result<T>returns,pass,fail,Result<NIL>, and nested call frames. ?fallback unwrap —expr ? fallback, nested explicit fallback, andawaitparser shape.??and?.— Optional/pointer null coalescing and safe navigation; not Result error handling.defaultsand?|— scoped fallback for expression chains and the primary-expression fallback rule.?!emphatic fallback — Result-only fallback unwrap with emphatic spelling; no source-level failsafe dispatch.raw,drop,_!,_?— explicit unwrap/discard surfaces and shorthand operand-shape details.- Contextual
catch—result catch (err) { handler }, error binding scope, and identifier compatibility. - Diagnostics and validation — common errors, decision IDs, bug fixtures, K coverage, and v0.33.6 counters.
Quick mental model
- Use
pass valueandfail codeinside ordinary functions. - Use
expr ? fallbackwhen you have an explicit fallback value. - Use
expr defaults fallbackorexpr ?| fallbackwhen a whole expression chain should fall back together. - Use
expr catch (err) { handler }when the fallback needs the error code. - Use
raw expr/_! expronly when you intentionally ignore failure state. - Use
drop expr/_? exprwhen you intentionally discard the result. - Use
??and?.for Optional/pointer/null shapes, not Result errors.
Validation snapshot (v0.33.6)
- Compiler CTest: 152/152 for the non-K-wrapper sweep at v0.33.5.
- K core tests: 192/192.
- K proofs: 13/13.
- Result bug regressions: bug646–bug674.
catchremains contextual, not a hard keyword.