Add structural custom iteration - #135
Open
itsfuad wants to merge 4 commits into
Open
Conversation
Recognize Next() returning an optional scalar item with one loop binding. Expand into checked calls, optional guards and scoped bindings before CFG, effects and ownership analysis; preserve built-in loops and central receiver guards. Keep temporary sources, complex places, richer items and cross-module method discovery outside this first slice. Add actionable diagnostics, phase regressions and runnable positive/negative fixtures. Share synthetic node IDs with default expansion, preserve lexical scope identity through InsertParent, centralize structural recognition and reuse generated-node indexing. These helpers protect semantic invariants and avoid duplicated phase logic. Validated with go test ./..., go run ./scripts/bundle.go, the full bundled x_test suite, gofmt and git diff --check. Refs #123.
Evaluate struct factories and literals once in an ordinary scoped binding. Generalize checked iteration evidence to a block so central cleanup handles source lifetime on exhaustion, break and return without affecting existing local cursor storage. Migrate CFG, typed-node indexing and HIR consumers. Add counted runtime factory coverage and cleanup-plan assertions; preserve canonical move checks and helpful diagnostics. No new production helpers or ownership policy. Validated with go test ./..., go run ./scripts/bundle.go, full bundled x_test suite, gofmt and git diff --check. Richer item binding and general place capture remain tracked in #123.
Preserve existing place identity, capture dynamic indexed places once, and materialize produced sources through ordinary bindings. Carry exact one-layer optional payload evidence so aggregate, owned, nested-optional, and reference items use canonical flow and ownership machinery.
Order type declarations by completion dependencies and refresh legal recursive generic instances in place. Reuse checked producer-call evidence and keep redundant optional syntax diagnostics in parser. Shared typeInstanceUnderlying helper keeps initial and completion construction identical while preserving cached type identity. Tests: go test ./... -count=1 Tests: CCACHE_DISABLE=1 go run ./scripts/bundle.go Tests: bundled peeper x_test suite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Next() -> ?Itemmethods for customfor item in sourceloopsProtocol
Next; exactly receiver, no extra/defaulted parametersnoneends iterationArchitecture
Generated operations are stored as checked semantic expansion and consumed by CFG, flow, effects, definite-init, ownership, HIR, and MIR. Lowering does not rediscover methods or synthesize hidden calls. Exact payload-depth evidence removes one outer optional layer without flattening optional Item.
Dynamic indexed places capture one reference according to receiver mutability, preserving one-time index evaluation without moving or copying cursor storage.
Validation
go test ./internal/semantics/typechecker ./internal/semantics/ownership ./internal/semantics/effect ./internal/semantics/definiteinit ./internal/ir/cfg ./internal/ir/hir/lower ./internal/ir/mir ./internal/lspgo test ./...go run ./scripts/bundle.goPEEPER_BIN=/home/itsfuad/Dev/Peeper/compiler/build/bin/peeper go test -count=1 ./x_testgofmton touched Go filesgit diff --checkSeparate follow-up boundaries
Cross-module method discovery and broader reference-storage/provenance capabilities remain owned by ordinary lookup and ownership systems. This change adds no iterator-specific workaround; future central improvements flow through the same checked expansion.
Closes #123