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

@@ -704,6 +704,7 @@
(set! result (merge result (dict mname mod-val))))))))
((= tag "type-def") nil)
((= tag "exception-def") nil)
((= tag "module-type-def") nil)
((= tag "open")
(let ((mod-val (ocaml-resolve-module-path (nth decl 1) env)))
(cond
@@ -884,6 +885,9 @@
;; exception E [of T] — purely declarative; raise+match
;; already work on tagged ctor values.
nil)
((= tag "module-type-def")
;; module type S = sig … end — no-op at runtime.
nil)
((or (= tag "open") (= tag "include"))
;; open M / include M — bring M's bindings into scope.
(let ((mod-val (ocaml-resolve-module-path (nth decl 1) env)))