diff --git a/lib/ocaml/baseline/expected.json b/lib/ocaml/baseline/expected.json index d5b441f4..7bf2e72e 100644 --- a/lib/ocaml/baseline/expected.json +++ b/lib/ocaml/baseline/expected.json @@ -8,6 +8,7 @@ "fizzbuzz.ml": 57, "list_ops.ml": 30, "module_use.ml": 3, + "mutable_record.ml": 10, "option_match.ml": 5, "quicksort.ml": 44, "sum_squares.ml": 385, diff --git a/lib/ocaml/baseline/mutable_record.ml b/lib/ocaml/baseline/mutable_record.ml new file mode 100644 index 00000000..41fb5302 --- /dev/null +++ b/lib/ocaml/baseline/mutable_record.ml @@ -0,0 +1,15 @@ +(* Baseline: mutable record fields via r.f <- v *) +type counter = { mutable count : int; mutable last : int } ;; + +let bump c = + c.count <- c.count + 1 ; + c.last <- c.count +;; + +let c = { count = 0; last = 0 } ;; +bump c ;; +bump c ;; +bump c ;; +bump c ;; +bump c ;; +c.count + c.last diff --git a/plans/ocaml-on-sx.md b/plans/ocaml-on-sx.md index d8d9ac78..41d171f2 100644 --- a/plans/ocaml-on-sx.md +++ b/plans/ocaml-on-sx.md @@ -407,6 +407,10 @@ _Newest first._ binary search tree (`type 'a tree = Leaf | Node of 'a * 'a tree * 'a tree`) with insert + in-order traversal. Tests parametric ADT, recursive match, List.append, List.fold_left. +- 2026-05-08 Phase 5.1 — mutable_record.ml baseline (14/14 pass). + Counter-style record with two mutable fields, bump function uses + `r.f <- v` to mutate. End-to-end validates type decl + record + literal + field access + field assignment + sequence operator. - 2026-05-08 Phase 2 — mutable record fields `r.f <- v` (+4 tests, 451 total). `<-` added to op-table at level 1 (same as `:=`). Eval short-circuits on `<-` to mutate the lhs's field via host SX