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:
@@ -1,23 +1,5 @@
|
||||
; Fieldtest mut-local #3 — evaluate the polynomial
|
||||
; p(x) = 2 x^3 - 3 x^2 + 5 x - 7
|
||||
; at x = 2.5 by Horner's method, using a Float mut-var as the running
|
||||
; accumulator and unrolling the four Horner steps as straight-line
|
||||
; assigns.
|
||||
;
|
||||
; Why this fits mut-local's scope: the accumulator is a Float, the
|
||||
; updates are straight-line (no iteration), and the mut form removes
|
||||
; the four nested let-rebinds an LLM-author would otherwise write
|
||||
; ("p1 = ..., p2 = p1*x + ..., p3 = p2*x + ...") — each rebind needing
|
||||
; a fresh name. Reusing one name for the running accumulator is the
|
||||
; natural shape, and mut supplies it.
|
||||
;
|
||||
; Hand-check (Horner): start with leading coeff 2.0, then for each
|
||||
; lower coefficient do acc = acc * x + c:
|
||||
; 2.0 * 2.5 + (-3) = 5.0 - 3 = 2.0
|
||||
; 2.0 * 2.5 + 5 = 5.0 + 5 = 10.0
|
||||
; 10.0 * 2.5 + (-7) = 25.0 - 7 = 18.0
|
||||
; Expected stdout: 18 (Float 18.0 via %g; print drops the trailing
|
||||
; ".0" the same way it does for the Float fixture mut_sum_floats.ail.)
|
||||
; Evaluate p(x) = 2x^3 - 3x^2 + 5x - 7 at x = 2.5 by Horner's method
|
||||
; via a let-threaded Float accumulator. Expected stdout: 18
|
||||
|
||||
(module mut-local_3_horner
|
||||
|
||||
@@ -25,10 +7,4 @@
|
||||
(type (fn-type (params) (ret (con Unit)) (effects IO)))
|
||||
(params)
|
||||
(body
|
||||
(app print
|
||||
(mut
|
||||
(var acc (con Float) 2.0)
|
||||
(assign acc (app - (app * acc 2.5) 3.0))
|
||||
(assign acc (app + (app * acc 2.5) 5.0))
|
||||
(assign acc (app - (app * acc 2.5) 7.0))
|
||||
acc)))))
|
||||
(app print (let acc 2.0 (let acc (app - (app * acc 2.5) 3.0) (let acc (app + (app * acc 2.5) 5.0) (let acc (app - (app * acc 2.5) 7.0) acc))))))))
|
||||
|
||||
Reference in New Issue
Block a user