give importers the private macros a pub one expands into

Only pub macros crossed, so one built on a private macro expanded in
the importer into a call of a C function nothing defines.
This commit is contained in:
2026-10-16 17:04:20 +03:00
parent 54a79ee75e
commit b5f9089bf1
4 changed files with 42 additions and 3 deletions

View File

@@ -30,7 +30,8 @@
;;;
;;; A module in a directory of its own finds its imports beside itself,
;;; not beside the unit importing it: shelf-app imports shelf/book, and
;;; book its siblings page, with `pub', and spine, without.
;;; book its siblings page, with `pub', and spine, without. A pub macro
;;; of page's expands into a private one, which crosses with it.
;;;
;;; csi -s check.scm
@@ -79,7 +80,7 @@
(output-of sexc "shelf-app.sex" "-o" "shelf-app" "--" "book.o" "page.o")))
(test "and the app runs through it"
'("pages 2 3")
'("pages 2 3" "number 2")
(output-of "./shelf-app"))
(test "the app runs through both"

View File

@@ -6,4 +6,5 @@
(printf "pages %d %d\n"
(. (second-page (& b)) number)
(. (page-after (second-page (& b))) number))
(printf "number %d\n" (page-number (second-page (& b))))
(return 0))

View File

@@ -2,3 +2,8 @@
(pub fn page-after ((p page)) page
(return #(page : (+ (. p number) 1))))
;;; number-of is private, but page-number expands into it, so importers
;;; are given both, the way a C header carries a helper macro too
(defmacro (number-of p) `(. ,p number))
(pub defmacro (page-number p) `(number-of ,p))