ocaml: phase 1+2 records {x=1;y=2} + with-update (+6 tests, 289 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 51s

Parser: { f = e; f = e; ... } -> (:record (F E)...). { base with f = e;
... } -> (:record-update BASE (F E)...). Eval builds a dict from field
bindings; record-update merges the new fields over the base dict — the
same dict representation already used for modules.

{ also added to at-app-start? so records are valid arg atoms. Field
access via the existing :field postfix unifies record/module access.

Record patterns deferred to a later iteration.
This commit is contained in:
2026-05-08 09:26:24 +00:00
parent 9473911cf3
commit 7fb65cd26a
4 changed files with 115 additions and 2 deletions

View File

@@ -714,6 +714,20 @@ cat > "$TMPFILE" << 'EPOCHS'
(epoch 1004)
(eval "(ocaml-run-program \"let g _ x = x + 1;; g 99 41\")")
;; ── Records ────────────────────────────────────────────────────
(epoch 1100)
(eval "(ocaml-run \"let r = { x = 1; y = 2 } in r.x\")")
(epoch 1101)
(eval "(ocaml-run \"let r = { x = 1; y = 2 } in r.x + r.y\")")
(epoch 1102)
(eval "(ocaml-run \"let r = { x = 1; y = 2 } in let r2 = { r with x = 99 } in r2.x + r2.y\")")
(epoch 1103)
(eval "(ocaml-run \"let p = { name = \\\"Bob\\\"; age = 30 } in p.name\")")
(epoch 1104)
(eval "(ocaml-run \"let p = { name = \\\"Bob\\\"; age = 30 } in p.age\")")
(epoch 1105)
(eval "(ocaml-run-program \"let r = { x = 1; y = 2 };; r.x + r.y\")")
EPOCHS
OUTPUT=$(timeout 180 "$SX_SERVER" < "$TMPFILE" 2>/dev/null)
@@ -1131,6 +1145,14 @@ check 1002 "let f _ = 1 in f 5" '1'
check 1003 "top-level let f () =" '7'
check 1004 "wildcard top-level" '42'
# ── Records ─────────────────────────────────────────────────────
check 1100 "record literal + access" '1'
check 1101 "record sum fields" '3'
check 1102 "record with-update" '101'
check 1103 "record string field" '"Bob"'
check 1104 "record int field" '30'
check 1105 "top-level record decl" '3'
TOTAL=$((PASS + FAIL))
if [ $FAIL -eq 0 ]; then
echo "ok $PASS/$TOTAL OCaml-on-SX tests passed"