Goal
Make builtin nullable ?T usable through full-CFG narrowing and ownership-safe payload access.
Settled source semantics
T promotes directly to ?T; none represents absence.
value != none proves presence on true edge; value == none proves presence on false edge. Reversed operands behave identically.
Proven ordinary value use unwraps one optional layer. Nested optionals need one proof per layer.
Inferred bindings use effective per-use type: let payload = value infers T under proof and ?T outside proof.
Explicit optional destinations and whole-carrier assignments preserve carrier type.
Terminating guards preserve surviving facts; joins intersect them; loops run to fixed point.
&& and || remain eager. RHS receives no short-circuit proof, while outgoing edges may use facts implied by completed boolean result.
Presence checks inspect without consuming.
Stable places
Narrow variables, fields, nested projections, constant-foldable indexes, and direct resolved integral binding indexes.
Direct binding indexes carry dependency identity. Assignment to index binding invalidates dependent facts.
Computed indexes such as items[i + 1] are unstable unless existing const evaluation reduces them.
Assignment to carrier or ancestor invalidates; payload-descendant mutation preserves outer presence.
Overlapping alias mutation invalidates affected facts.
Mutable-reference and known raw-pointer calls invalidate overlapping facts after argument evaluation.
Unknown raw-pointer effects invalidate all potentially reachable facts. Calls invalidate mutable module-global facts.
Scope exit removes facts rooted in exited bindings.
Ownership boundary
Copyable payload and shared-reference payload reads preserve carrier.
Moving move-only payload from direct named local/parameter optional consumes whole carrier; reinitialization restores it.
Field/index/pointee payloads may be narrowed and borrowed, but move-only partial extraction is rejected.
Mutable-reference payload transfer follows existing transfer and borrow-conflict rules.
Compiler work
Insert explicit FlowTyped phase: Typechecked -> CFG -> FlowTyped -> DefiniteInit -> Ownership -> Usage -> HIR.
Store per-function site facts, refined expression types, payload evidence, carrier/value origins, and index dependencies in module-owned flow result.
Reuse canonical typechecker expression logic through refinement injection; do not add a second AST typing switch.
Reuse and extend internal/semantics/place origin/overlap logic; do not add a second alias walker.
Add T0041 for unproven payload use and T0042 for unstable narrowing subjects.
Ownership consumes flow evidence while preserving cleanup planning.
Add explicit optional-presence and optional-payload HIR/MIR operations.
LLVM lowers through named present and value layout fields.
Representation and explicit non-scope
Keep tagged {i1, payload} representation for every optional in this issue.
Niche layout remains Add optional niche layouts #30 and cannot affect source semantics.
No Some, unwrap operator, optional pattern, fallback operator, extraction operator, optional chaining, optional-to-optional equality, or new syntax.
Dependencies
Validation
Presence polarity, reversed operands, guards, joins, loops, eager boolean results, unreachable paths, and nested optionals.
Inference, explicit carrier contexts, shadowing, fields, nested fields, constant indexes, binding indexes, and computed-index rejection.
Exact/ancestor/descendant assignment, alias, call, global, index-dependency, and scope-exit invalidation.
Copy/borrow/move ownership, direct owner consumption/reinitialization, use-after-consume, conditional cleanup, and rejected partial moves.
Explicit HIR/MIR operations, tagged 32-bit/64-bit LLVM layout, payload projection, presence checks, and drops.
Positive runtime plus applicable negative x_test fixtures with bundled compiler.
LSP refined hover, diagnostics, incremental reset, and snapshot reuse.
Goal
Make builtin nullable
?Tusable through full-CFG narrowing and ownership-safe payload access.Settled source semantics
Tpromotes directly to?T;nonerepresents absence.value != noneproves presence on true edge;value == noneproves presence on false edge. Reversed operands behave identically.let payload = valueinfersTunder proof and?Toutside proof.&&and||remain eager. RHS receives no short-circuit proof, while outgoing edges may use facts implied by completed boolean result.Stable places
items[i + 1]are unstable unless existing const evaluation reduces them.Ownership boundary
Compiler work
FlowTypedphase:Typechecked -> CFG -> FlowTyped -> DefiniteInit -> Ownership -> Usage -> HIR.internal/semantics/placeorigin/overlap logic; do not add a second alias walker.presentandvaluelayout fields.Representation and explicit non-scope
{i1, payload}representation for every optional in this issue.Some, unwrap operator, optional pattern, fallback operator, extraction operator, optional chaining, optional-to-optional equality, or new syntax.Dependencies
Validation
x_testfixtures with bundled compiler.