Add optional-producing call iteration - #135
Merged
Merged
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
Member
Author
|
PR description correction: this change implements optional-producing call iteration, not an implicit Valid form is Earlier issue/PR comments describe superseded design exploration and remain historical. |
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
for item in producerCall()syntax for ordinary calls returning?ItemContract
for item in producerCall()?T;noneends iteration and a present result binds oneTcontinueperforms another complete producer-call attempt;breakandreturndo not advance againindex, valuebehavior remains unchangedNextprotocol, source capture, iterator interface, vtable, boxing, generic constraint, or tuple prerequisiteArchitecture
Generated operations are stored as checked semantic expansion and consumed by CFG, flow, effects, definite-init, ownership, cleanup, HIR, and MIR. Lowering does not rediscover calls or synthesize hidden producer behavior. The complete producer call intentionally remains inside the loop because it evaluates once per attempt under ordinary call semantics.
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 test -race ./...go run ./scripts/bundle.goPEEPER_BIN=$PWD/build/bin/peeper go test -count=1 ./x_testgofmtandgit diff --checkCloses #123