forked from alex-eg/sex
check what a module's importers can see of its types
An importer is given the pub forms and nothing else, so a pub form naming a private type, or one from an import without pub, compiled in its module and failed in every importer with `unknown type name'. The pub forms are checked as the module itself is compiled. A record, struct, union or sum behind a pointer needs only declaring, so its bodyless declaration goes out ahead of them -- the opaque handle that (pub record T) already gave by hand. Held by value it needs its body, and a typedef or an enum has no declaration short of its definition: those are errors at the pub form, saying what would do instead. A name Sex has no declaration for is left to C. An importer may now be handed a declaration after the definition it declares, so a bodyless aggregate no longer replaces known fields. Fixes #57, #58.
This commit is contained in:
8
tests/modules/ledger.sex
Normal file
8
tests/modules/ledger.sex
Normal file
@@ -0,0 +1,8 @@
|
||||
;;; A module greet.sex imports without `pub'. greet-app.sex never
|
||||
;;; imports it, yet holds a (* ledger) that greet hands out: what greet
|
||||
;;; exports has to declare the type for it.
|
||||
|
||||
(pub record ledger ((total int)))
|
||||
|
||||
(pub fn ledger-add ((l (* ledger)) (n int)) void
|
||||
(+= (. l total) n))
|
||||
Reference in New Issue
Block a user