feat(types): option (some/none) safety type (#53)
Types phase 3 — the option/result safety pair. result/ok/err/try shipped in #46; this adds its companion option: - some(v) -> option (present value; any i32-width scalar) - none() -> option (empty; no magic -1 sentinel) - is_some / is_none -> bool - unwrap_or(o, fallback) -> int A heap %Option = { i32 present, i32 value }, bare builtins guarded by find_fn (a user fn of the same name still wins), gated by g_uses_option so unused programs compile byte-identically — same idiom as result. Wired: emit_call codegen + %Option decl (emit_decl) + g_uses_option (emit_core), reseeded seed, vocabulary sync (header/JetBrains/TextMate), builtin docs + inventory, and a self-asserting example (examples/library/optionresult.ludic + feat_case). All suites green incl. golden renders byte-identical and the bootstrap fixpoint. Tagged-union enums (variant payloads + binding match + exhaustiveness) are the deep type-system feature, split out to #56. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
5dc8394f22
commit
790eda6f73
17 changed files with 5526 additions and 4905 deletions
11
changes/types-option.md
Normal file
11
changes/types-option.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
bump: minor
|
||||
type: feat
|
||||
**`option` — a maybe-a-value type (#53, types phase 3).** The companion to
|
||||
`result` (#46): `some(v)` wraps a present value (any i32-width scalar), `none()`
|
||||
is the empty case — a missing value with no magic `-1` sentinel — and
|
||||
`is_some`/`is_none`/`unwrap_or(o, fallback)` test and read it. A heap
|
||||
`%Option = { i32 present, i32 value }`, additive and gated, so a program that
|
||||
does not use it compiles byte-identically. With `result`/`ok`/`err`/`try`
|
||||
already shipped, the concrete option/result safety types of phase 3 are done;
|
||||
general tagged-union enums (variant payloads + binding `match` + exhaustiveness)
|
||||
are tracked separately in #56.
|
||||
Loading…
Add table
Add a link
Reference in a new issue