Files
rose-ash/lib/ocaml/baseline/mutable_record.ml
giles 50a219b688
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 50s
ocaml: phase 5.1 mutable_record.ml baseline (14/14 pass)
Counter-style record with two mutable fields. Validates the new
r.f <- v field mutation end-to-end through type decl + record literal
+ field access + field assignment + sequence operator.

  type counter = { mutable count : int; mutable last : int }
  let bump c = c.count <- c.count + 1 ; c.last <- c.count

After 5 bumps: count=5, last=5, sum=10.
2026-05-08 18:43:19 +00:00

16 lines
280 B
OCaml

(* 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