You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Implicit main: a helper fn cannot see the script's top-level bindings ("undefined variable") — the spec does not say whether they are globals #2951
Conformance audit 2026-11-02. AGENTS.md: "a .w file needs no fn main; top-level statements are the program, beside helper fns". What a helper sees is unspecified, and today it sees nothing:
error: undefined variable (count, in bump and in peek)
Every one-liner/script shape that keeps state (a counter, a table a helper fills) hits this and must pass the value through parameters. The spec has no text for the implicit main's scope (§18.5 names the mode; nothing says whether a top-level let/var is a module global or a local of the synthesized main). Needs Eric's ruling; prediction: a script's top-level bindings are the module's globals (as in Python, and as D175 already orders module globals), so helpers see them.
D184: ruled (spec v7.35 §29.15, #2970): a script's top-level bindings are module globals assigned in statement order; a read before its statement is D175's compile-time error. Implementation next.
D184 amended by Eric (spec v7.35 §29.15, merged): a script's top-level binding is a local of the implicit main, typed by its uses in main; a helper that names it captures it (observe or mutate, never consume; an ephemeral capture makes the helper non-escaping); helper locals shadow it (D173). Implementation follows on a new branch; the globals WIP (d184-script-globals) is superseded.
Implemented by #2983 under the amended D184 (§29.15): a script's top-level bindings are locals of the implicit main; a helper that names one captures it. The non-escaping rule for a captured view is #2984.
Activity
ehartford commentedon Nov 2, 2026
D184: ruled (spec v7.35 §29.15, #2970): a script's top-level bindings are module globals assigned in statement order; a read before its statement is D175's compile-time error. Implementation next.
ehartford commentedon Nov 2, 2026
D184 amended by Eric (spec v7.35 §29.15, merged): a script's top-level binding is a local of the implicit main, typed by its uses in main; a helper that names it captures it (observe or mutate, never consume; an ephemeral capture makes the helper non-escaping); helper locals shadow it (D173). Implementation follows on a new branch; the globals WIP (d184-script-globals) is superseded.
ehartford commentedon Nov 2, 2026
Implemented by #2983 under the amended D184 (§29.15): a script's top-level bindings are locals of the implicit main; a helper that names one captures it. The non-escaping rule for a captured view is #2984.