keep a module's public forms in declaration order

read-public-interface folded with cons and never reversed, so an
imported pub fn whose prototype named a type declared above it in the
same module was pasted before that type, and the unit did not compile.
This commit is contained in:
2026-10-03 22:28:14 +03:00
parent a860da6d7e
commit 2512d52dd1

View File

@@ -65,12 +65,16 @@
module-path))))
(define (read-public-interface module-path)
;; pub fns are reduced to prototypes, other pub forms are just pasted
;; pub fns are reduced to prototypes, other pub forms are just pasted.
;; Declaration order is kept: a module that declares a type and then a
;; pub fn taking it has to paste them that way round, or the prototype
;; names a type C has not seen.
(let ((raw-forms (read-from-file module-path)))
(fold
process-public-interface-form
(list)
raw-forms)))
(reverse
(fold
process-public-interface-form
(list)
raw-forms))))
(define (public-fn-interface raw-form)
;; (pub fn name args ret . body) -> prototype, keeping a docstring so