Skip to content

Add optional narrowing and payload access - #87

Open
itsfuad wants to merge 1 commit into
mainfrom
feature/optional-narrowing
Open

Add optional narrowing and payload access#87
itsfuad wants to merge 1 commit into
mainfrom
feature/optional-narrowing

Conversation

@itsfuad

@itsfuad itsfuad commented Aug 23, 2026

Copy link
Copy Markdown
Member

Summary

  • add module-owned FlowTyped results between CFG and definite initialization
  • narrow stable optional variables, fields, nested projections, constant indexes, and resolved binding indexes across full CFG fixed points
  • preserve carrier types in explicit optional contexts while exposing inferred payload types at proven uses
  • invalidate facts through assignments, aliases, index dependencies, calls, raw pointers, globals, and scope exit
  • make ownership consume flow payload/origin evidence and lower presence/payload operations explicitly through HIR, MIR, and LLVM
  • publish refined hover types and flow diagnostics through incremental LSP snapshots

Ownership boundary

  • copyable and shared-reference payload reads preserve optional carrier
  • moving move-only payload from direct named local or parameter consumes whole carrier and supports reinitialization
  • move-only extraction from fields, indexes, pointees, and other partial places remains rejected

Representation boundary

  • every optional remains tagged {present, value} in this PR
  • niche representation remains separate in Add optional niche layouts #30
  • no Some, unwrap, fallback, chaining, patterns, optional equality, or other new syntax

Validation

  • CCACHE_DISABLE=1 GOCACHE=/tmp/peeper-go-cache go test -count=1 ./...
  • CCACHE_DISABLE=1 GOCACHE=/tmp/peeper-go-cache go vet ./...
  • CCACHE_DISABLE=1 GOCACHE=/tmp/peeper-go-cache go test -race -count=1 ./...
  • CCACHE_DISABLE=1 GOCACHE=/tmp/peeper-go-cache bash scripts/build.sh
  • CCACHE_DISABLE=1 GOCACHE=/tmp/peeper-go-cache PEEPER_BIN="$PWD/build/bin/peeper" go test -count=1 ./x_test
  • git diff --check

Closes #28.

Follow-up: #31 can use delivered optional payload contract for iterator next -> ?T; #30 remains open for niche layouts.

Insert FlowTyped between CFG and ownership consumers, centralize effective expression types and carrier/value place resolution, and lower optional presence and payload operations explicitly through HIR, MIR, and LLVM.

Module.EffectiveExprType, place.Resolve, and PayloadOrigins centralize shared flow/place invariants; no compatibility wrappers or parallel walkers remain.

Validated with uncached go tests, go vet, race tests, build script, bundled x_test fixtures, formatting audit, and git diff --check.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add optional narrowing and payload access

1 participant