ocaml: phase 5.1 baseline OCaml programs (5/5 pass) + lookahead boundary
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 33s

lib/ocaml/baseline/{factorial,list_ops,option_match,module_use,sum_squares}.ml
exercised through ocaml-run-program (file-read F). lib/ocaml/baseline/
run.sh runs them and compares against expected.json — all 5 pass.

To make module_use.ml (with nested let-in) parse, parser's
skip-let-rhs-boundary! now uses has-matching-in? lookahead: a let at
depth 0 in a let-decl rhs opens a nested block IFF a matching in
exists before any decl-keyword. Without that in, the let is a new
top-level decl (preserves test 274 'let x = 1 let y = 2').

This is the first piece of Phase 5.1 'vendor a slice of OCaml
testsuite' — handcrafted fixtures for now, real testsuite TBD.
This commit is contained in:
2026-05-08 13:33:24 +00:00
parent 756d5fba64
commit de7be332c8
9 changed files with 217 additions and 17 deletions

View File

@@ -214,10 +214,12 @@ SX CEK evaluator (both JS and OCaml hosts)
eval-core, phase2-refs, phase2-loops, phase2-function, phase2-exn,
phase3-adt, phase4-modules, phase5-hm, phase6-stdlib, let-and,
phase1-params, misc), and emits `scoreboard.json` + `scoreboard.md`.
- [ ] Vendor a slice of the OCaml testsuite at `lib/ocaml/baseline/`
and feed it through `ocaml-run-program`, scoring per-file
conformance. _(Pending — needs more stdlib coverage and ADT type
decls to make most testsuite files runnable.)_
- [~] Baseline OCaml programs at `lib/ocaml/baseline/` exercised through
`ocaml-run-program`. Currently 5/5: factorial.ml (recursion),
list_ops.ml (List.map + fold_left), option_match.ml (option +
pattern match), module_use.ml (module + ref + closure +
sequenced calls), sum_squares.ml (for-loop + ref). Real OCaml
testsuite vendoring is the next step.
### Phase 5 — Hindley-Milner type inference
@@ -370,6 +372,15 @@ the "mother tongue" closure: OCaml → SX → OCaml. This means:
_Newest first._
- 2026-05-08 Phase 5.1 — `lib/ocaml/baseline/` with five sample OCaml
programs (.ml files), driven by `lib/ocaml/baseline/run.sh` through
`ocaml-run-program (file-read F)`. All 5/5 pass: factorial,
list_ops, option_match, module_use (module + ref + closure +
sequenced calls), sum_squares (for-loop). To make module_use parse,
parser's `skip-let-rhs-boundary!` now lookaheads for a matching `in`
before any decl-keyword — distinguishes nested let-in from a new
top-level decl. Test 274 (`let x = 1 let y = 2`) still works because
its body has no inner `in`.
- 2026-05-08 Phase 5 — HM with user `type` declarations (+6 tests, 363
total). `ocaml-hm-ctors` is now a mutable list cell; user type-defs
register their constructors via `ocaml-hm-register-type-def!`. New