Repository navigation
D184: a script's top-level bindings are locals of the implicit main; a helper captures them (§29.15) - #2983
Merged
Conversation
ehartford
force-pushed
the
d184-captures
branch
from
November 2, 2026 19:13
0490b7f to
90fc1aa
Compare
…a helper that names one captures it (§29.15) Parser: a script's named let/var stays a local of main; the pool records the script's bindings and the file's top-level fns (its helpers), and the marks travel through the comptime transform. Sema: a helper is checked where main calls it, never ahead of main's body; its body sees the script's bindings as level-0 captures (a parameter or local shadows one, D173; a helper's read settles an integer-literal binding's width, and a later use in main that disagrees names both sites; a binding a helper reads gets storage both can reach; a helper that consumes a capture is refused, Law 5). A read in a helper reached before the binding's statement has run is a compile-time error from the static call graph. MIR marks a captured binding's local as storage-backed; both backends define the storage. Tests: behav_d184_script_captures, behav_d184_captures_view_and_mutation, err_d184_read_before_statement, err_d184_helper_consumes_capture, err_d184_helper_settles_width; the 149 script-style behavior tests pass. Follow-up: a helper that captures a view is non-escaping (a spawn or a value use of it is refused) is not yet enforced.
ehartford
force-pushed
the
d184-captures
branch
from
November 2, 2026 20:42
90fc1aa to
f338bb0
Compare
Contributor
Author
|
Battery green on f338bb0 ( |
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.
Implements the amended D184 (#2979, spec v7.35 §29.15; #2951). Parser records the script's bindings and helpers; Sema injects captures into a helper checked at main's call site, settles widths, refuses consumption (Law 5) and reads before the binding's statement; MIR and both backends give captured bindings storage. Five new fixtures; 149 script-style behavior tests pass under stage1. Follow-up filed for the non-escaping rule of a view capture. Battery to follow.