iter remove-mut-var-assign.1: atomic removal of mut/var/assign
mut/var/assign removed from AILang entirely and atomically. Deleted: Term::Mut/Term::Assign/struct MutVar; the three Form-A keywords + parse_mut/parse_assign + grammar EBNF; the 4 mut CheckError variants; the mut_scope_stack synth threading (param dropped from synth + every internal/external/test caller); the two lower_term arms; and every exhaustive no-_ Term::Mut/Term::Assign match arm across 17 source files — cut in lockstep with DESIGN.md, fixtures, the drift trio, carve-out and roadmap so the schema is honest at every commit. No catch-all wildcard introduced (verified). loop/recur + let/if are the surviving forms. The shared codegen alloca machinery survives (loop reuses it): mut_var_allocas renamed binder_allocas (representation-only, loop codegen byte-identical) and the shared Term::Lam escape guard simplified to !loop_stack.is_empty() with the loop half (LoopBinderCapturedByLambda) byte-equivalent. Feature-acceptance applied inverted: the removed feature fails clause 2 (redundant) and clause 3 (IS the iterated-mutable-state bug class). Behaviour preservation is executable: mut_counter/mut_sum_floats still print 55 after the faithful let/if rewrite. The removal is made executable by the new mut_removed_pin.rs (4 must-fail pins). Independent verification: cargo test --workspace 605/0, zero residual mut symbols in any crate source, loop/recur non-regression all green (55 / 500000500000 / infinite-compiles / the lambda_capturing_loop_binder pin), roundtrip_cli PASS. One DONE_WITH_CONCERNS: a 4th recurrence of the recon-undercount class (in-source mod tests + a drift-pin fn + 5 orphaned mut .ail.json carve-outs + a non-enumerated E0599); all resolved within implementer remit, no behaviour change. Milestone-close audit then fieldtest remain. spec docs/specs/2026-05-18-remove-mut-var-assign.md (grounding PASS) plan docs/plans/remove-mut-var-assign.1.md
This commit is contained in:
+12
-37
@@ -1,62 +1,37 @@
|
||||
(module mut
|
||||
|
||||
(fn mut_empty
|
||||
(doc "Iter mut.1 — empty mut block; body is a single Int literal.")
|
||||
(doc "Empty block; body is a single Int literal.")
|
||||
(type (fn-type (params) (ret (con Int))))
|
||||
(params)
|
||||
(body (mut 0)))
|
||||
(body 0))
|
||||
|
||||
(fn mut_single_var
|
||||
(doc "Iter mut.1 — one var, one assign, final expression reads the var.")
|
||||
(doc "let-rebind: x starts at 0, the block value is x + 1.")
|
||||
(type (fn-type (params) (ret (con Int))))
|
||||
(params)
|
||||
(body
|
||||
(mut
|
||||
(var x (con Int) 0)
|
||||
(assign x (app + x 1))
|
||||
x)))
|
||||
(body (let x 0 (let x (app + x 1) x))))
|
||||
|
||||
(fn mut_two_vars
|
||||
(doc "Iter mut.1 — two vars, two assigns, final expression combines them.")
|
||||
(doc "Two let-threaded scalars combined into the block value.")
|
||||
(type (fn-type (params) (ret (con Float))))
|
||||
(params)
|
||||
(body
|
||||
(mut
|
||||
(var sum (con Float) 0.0)
|
||||
(var count (con Int) 0)
|
||||
(assign sum (app + sum 1.0))
|
||||
(assign count (app + count 1))
|
||||
(app + sum (app int_to_float count)))))
|
||||
(body (let sum 0.0 (let count 0 (let sum (app + sum 1.0) (let count (app + count 1) (app + sum (app int_to_float count))))))))
|
||||
|
||||
(fn mut_nested_shadow
|
||||
(doc "Iter mut.1 — outer var shadowed by inner mut block's var of the same name.")
|
||||
(doc "Nested let shadowing; inner binding is the block value.")
|
||||
(type (fn-type (params) (ret (con Int))))
|
||||
(params)
|
||||
(body
|
||||
(mut
|
||||
(var x (con Int) 10)
|
||||
(assign x (app + x 1))
|
||||
(mut
|
||||
(var x (con Int) 100)
|
||||
(assign x (app + x 1))
|
||||
x))))
|
||||
(body (let x 10 (let x (app + x 1) (let x 100 (let x (app + x 1) x))))))
|
||||
|
||||
(fn mut_returns_bool
|
||||
(doc "Iter mut.1 — exercise Bool as a supported scalar var type.")
|
||||
(doc "Bool scalar threaded through let; block value is the latest binding.")
|
||||
(type (fn-type (params) (ret (con Bool))))
|
||||
(params)
|
||||
(body
|
||||
(mut
|
||||
(var flag (con Bool) false)
|
||||
(assign flag true)
|
||||
flag)))
|
||||
(body (let flag false (let flag true flag))))
|
||||
|
||||
(fn mut_returns_unit
|
||||
(doc "Iter mut.1 — exercise Unit as the supported scalar zero case.")
|
||||
(doc "Unit scalar threaded through let; block value is the latest binding.")
|
||||
(type (fn-type (params) (ret (con Unit))))
|
||||
(params)
|
||||
(body
|
||||
(mut
|
||||
(var u (con Unit) (lit-unit))
|
||||
(assign u (lit-unit))
|
||||
u))))
|
||||
(body (let u (lit-unit) (let u (lit-unit) u)))))
|
||||
|
||||
Reference in New Issue
Block a user