check the constants a module's interface hands its importers

An array bound in a pub record, or a name in a pub define's body, is
the importer's to resolve too, and a private define, or one from an
import without pub, failed there as an undeclared identifier. Found in
vs-map-viewer once its units stopped importing everything. A constant
has no declaration short of itself, so it is an error at the pub form.
This commit is contained in:
2026-10-09 18:21:11 +03:00
parent 5b7ed9793b
commit a8f8b23b49
2 changed files with 34 additions and 9 deletions

View File

@@ -351,4 +351,17 @@ ahead of its pub forms."
"only a handle"))
(test "which is all it takes"
'()
(interface-of "(pub record h) (record h ((n int))) (pub fn f ((x (* h))) void)"))))
(interface-of "(pub record h) (record h ((n int))) (pub fn f ((x (* h))) void)"))
;; A constant has no declaration either, and an array bound or a
;; pub define's body hands its name to importers all the same
(test-assert "a constant sizing a pub record's array"
(interface-reports? "(define N 4) (pub record r ((xs [int N])))"
"this define, and C declares one only by defining it"))
(test-assert "or used by a pub define"
(interface-reports? "(define N 4) (pub define M (* 2 N))" "this define"))
(test "is fine when pub"
'()
(interface-of "(pub define N 4) (pub record r ((xs [int N])))"))
(test "as is a literal bound"
'()
(interface-of "(pub record r ((xs [int 4])))"))))