ocaml: phase 4 module type S = sig … end parser (+3 tests, 389 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 33s

module type S = sig DECLS end is parsed-and-discarded — sig..end
balanced skipping in parse-decl-module-type. AST (:module-type-def
NAME). Runtime no-op (signatures are type-level only).

Allows real OCaml programs with module type decls to parse and run
without stripping the sig blocks.
This commit is contained in:
2026-05-08 15:11:45 +00:00
parent 76ccbfbab6
commit ad252088c3
4 changed files with 69 additions and 3 deletions

View File

@@ -191,9 +191,10 @@ SX CEK evaluator (both JS and OCaml hosts)
- [x] `module M = struct let x = 1 let f y = x + y end` → SX dict
`{"x" 1 "f" <fn>}`.
- [~] `module type S = sig val x : int val f : int -> int end` — signature
annotations are parsed-and-skipped (`skip-optional-sig`); typed
checking deferred to Phase 5.
- [x] `module type S = sig val x : int val f : int -> int end` parses
via `parse-decl-module-type`. Signature contents are skipped
(sig..end nesting tracked) — runtime no-op since types are
structural. AST: `(:module-type-def NAME)`.
- [x] `module M : S = struct ... end` — coercive sealing (signature ignored).
- [x] `functor (M : S) -> struct ... end` via shorthand `module F (M) = …`.
- [x] `module F = Functor(Base)` — functor application; multi-param via
@@ -376,6 +377,11 @@ the "mother tongue" closure: OCaml → SX → OCaml. This means:
_Newest first._
- 2026-05-08 Phase 4 — `module type S = sig … end` parser (+3 tests,
389 total). Signatures are parsed-and-discarded — sig..end balanced
skipping. AST: `(:module-type-def NAME)`. Runtime no-op (signatures
are type-level). Allows real OCaml code with module type decls to
parse and run without removing the sig blocks.
- 2026-05-08 Phase 1+3 — record patterns `{ f = pat; … }` (+4 tests,
386 total). Parser adds `(:precord (FIELD PAT) …)` alongside
the existing record-literal `{` handling. Eval matches against