; Fieldtest mut-local #5 — deliberate probe of the seal-by-construction ; promise: try to lift a mut-var into a lambda closure. ; ; Spec §"Out of scope": "Lambda capture of a mut-var. A lambda body ; whose free vars include a mut-var of an enclosing Term::Mut is ; rejected at typecheck with CheckError::MutVarCapturedByLambda." ; ; This file is EXPECTED TO FAIL at `ail check` with the ; `mut-var-captured-by-lambda` diagnostic. The purpose is to probe: ; - that the diagnostic actually fires ; - that its rendered text is actionable ; - that it points at the lambda site, not somewhere else ; ; The shape: a mut block declares `count`, builds a closure that would ; close over `count`, and tries to return the closure. An LLM-author ; might write this naïvely thinking "I just need a small callback that ; updates the running count" — exactly the shape the seal forbids. (module mut-local_5_lambda_capture_probe (fn make_bumper (type (fn-type (params (con Int)) (ret (fn-type (params (con Int)) (ret (con Int)))))) (params seed) (body (mut (var count (con Int) 0) (assign count seed) (lam (params (typed n (con Int))) (ret (con Int)) (body (app + n count)))))) (fn main (type (fn-type (params) (ret (con Unit)) (effects IO))) (params) (body (app print (app (app make_bumper 10) 5)))))