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

@@ -956,6 +956,14 @@ cat > "$TMPFILE" << 'EPOCHS'
(epoch 2603)
(eval "(ocaml-run \"match { x = 5; y = 2 } with | { x = 1; y = y } -> y | _ -> 0\")")
;; ── module type S = sig … end ─────────────────────────────────
(epoch 2700)
(eval "(ocaml-parse-program \"module type S = sig val x : int val f : int -> int end\")")
(epoch 2701)
(eval "(ocaml-run-program \"module type S = sig val x : int end ;; module M = struct let x = 42 end ;; M.x\")")
(epoch 2702)
(eval "(ocaml-parse-program \"module type EMPTY = sig end\")")
EPOCHS
OUTPUT=$(timeout 180 "$SX_SERVER" < "$TMPFILE" 2>/dev/null)
@@ -1512,6 +1520,11 @@ check 2601 "match record name+age" '30'
check 2602 "match record literal x=1" '2'
check 2603 "match record literal fail" '0'
# ── module type S = sig … end ──────────────────────────────────
check 2700 "module type S parses" '("module-type-def" "S")'
check 2701 "module type then module" '42'
check 2702 "module type EMPTY" '("module-type-def" "EMPTY")'
TOTAL=$((PASS + FAIL))
if [ $FAIL -eq 0 ]; then
echo "ok $PASS/$TOTAL OCaml-on-SX tests passed"