Files
AILang/examples/fieldtest/cut55_2_consume_map.ail
T
Brummel e25580e3a3 test(cutover): live accept/reject corpus for the #55 ownership surface
Wires the #55-cutover fieldtest into a durable regression net. The
fieldtest exercised the post-cutover ParamMode={Own,Borrow} surface as a
downstream LLM author would and produced 12 fixtures + a report; left as
loose files they would be dead fixtures that drift. This commits them as
a protected property.

crates/ail/tests/cut55_cutover_surface.rs — one table-driven test running
each fixture through `ail check` and asserting accept (exit 0) or reject
at the right pipeline stage. Reject rows key on the bracketed diagnostic
CODE (consume-while-borrowed, borrow-over-value, borrow-return-not-permitted,
surface-parse-error), NOT message text, so the test is decoupled from the
diagnostic-wording improvement tracked separately.

examples/fieldtest/cut55_*.ail — the corpus. cut55_2c is the #58 repro
(now correctly rejected). cut55_2b was misanalysed by the fieldtest as a
consume-while-borrowed reject; in fact bump's recursive param is
(borrow List) so the tail is only borrowed, never consumed into an own
slot — `ail check` correctly accepts it. Renamed to
cut55_2b_borrow_traversal_clean and recast as the #58 false-positive
guard (a borrow-position use of a heap sub-binder must stay accepted).
cut55_1b similarly does not fire over-strict-mode (its recursive call
consumes the tail, so the lint's consume_count==0 premise fails) — comment
corrected; it is a plain accept. cut55_1c is the genuine over-strict-mode
example (accepts exit 0, emits the warning).

docs/specs/0065-eliminate-implicit-mode fieldtest report — moved 2c to
the reject set, added the 2b false-positive-guard section, marked the
double-free spec_gap RESOLVED (it shipped as the #58 fix).

Relates to #55.
2026-06-02 00:45:21 +02:00

52 lines
1.6 KiB
Plaintext

; Fieldtest cut55-2 — decision (b): consume/transform a heap value.
;
; bump rebuilds the list with each element +1. It moves the tail `t` into
; a recursive call and packs the new head into a fresh Cons. The input
; allocation is consumed (reused conceptually). This is `own` territory:
; the author writes `(own (con List))` for xs without hesitation, since
; the value is transformed and not merely read.
;
; Expected: ail check -> ok. ail run -> prints 11, 21, 31 (each +1).
(module cut55_2_consume_map
(data List
(ctor Nil)
(ctor Cons (con Int) (con List)))
(fn bump
(doc "Own xs; return a new list with every element incremented.")
(type
(fn-type
(params (own (con List)))
(ret (own (con List)))))
(params xs)
(body
(match xs
(case (pat-ctor Nil) (term-ctor List Nil))
(case (pat-ctor Cons h t)
(term-ctor List Cons (app + h 1) (app bump t))))))
(fn print_all
(doc "Own xs; print each element on its own line, consuming the list.")
(type (fn-type (params (own (con List))) (ret (own (con Unit))) (effects IO)))
(params xs)
(body
(match xs
(case (pat-ctor Nil) (lit-unit))
(case (pat-ctor Cons h t)
(seq
(seq (app print h) (do io/print_str "\n"))
(app print_all t))))))
(fn main
(type (fn-type (params) (ret (own (con Unit))) (effects IO)))
(params)
(body
(let xs
(term-ctor List Cons 10
(term-ctor List Cons 20
(term-ctor List Cons 30
(term-ctor List Nil))))
(app print_all (app bump xs))))))