count a unit among its own imports

Two modules importing each other with pub hand the unit its own
interface back, and its types were defined twice.
This commit is contained in:
2026-10-19 14:18:56 +03:00
parent 4bdc0e57a7
commit b285174a22
6 changed files with 45 additions and 2 deletions

View File

@@ -15,6 +15,7 @@
(export
get-modules-public-forms
mark-imported!
load-persistent-module-paths
check-public-interface
module-dependencies
@@ -26,6 +27,12 @@
;;; once)
(define +imported-modules+ (list))
;;; The unit is one of its own imports from the start: two modules that
;;; import each other with pub hand it its own interface back otherwise,
;;; and its types are defined twice
(define (mark-imported! path)
(set! +imported-modules+ (cons (normalize-pathname path) +imported-modules+)))
(define (get-modules-public-forms import-form)
;; How Sex handles modules:
;; For each module IMPORT-FORM names, construct path, find module by
@@ -40,10 +47,11 @@
(module-path (locate-module name directory)))
(unless module-path
(sex-error form "Failed to find module" name (get-module-paths directory)))
(if (member module-path +imported-modules+)
(if (member (normalize-pathname module-path) +imported-modules+)
(list)
(begin
(set! +imported-modules+ (cons module-path +imported-modules+))
(set! +imported-modules+ (cons (normalize-pathname module-path)
+imported-modules+))
(read-public-interface module-path)))))
;;; An import is looked for beside the file it is written in, so a