* module/language/tree-il/primitives.scm (resolve-primitives!): Resolve public module-refs to primitives.
* test-suite/tests/tree-il.test: New tests for primitive resolution. --- module/language/tree-il/primitives.scm | 16 +++++++++------- test-suite/tests/tree-il.test | 10 +++++++++- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/module/language/tree-il/primitives.scm b/module/language/tree-il/primitives.scm index 3c6769d..1dcab20 100644 --- a/module/language/tree-il/primitives.scm +++ b/module/language/tree-il/primitives.scm @@ -265,13 +265,15 @@ (module-variable mod name))) (lambda (name) (make-primitive-ref src name)))) ((<module-ref> src mod name public?) - ;; for the moment, we're disabling primitive resolution for - ;; public refs because resolve-interface can raise errors. - (let ((m (and (not public?) (resolve-module mod)))) - (and m - (and=> (hashq-ref *interesting-primitive-vars* - (module-variable m name)) - (lambda (name) (make-primitive-ref src name)))))) + (and=> (and=> (resolve-module mod) + (if public? + module-public-interface + identity)) + (lambda (m) + (and=> (hashq-ref *interesting-primitive-vars* + (module-variable m name)) + (lambda (name) + (make-primitive-ref src name)))))) ((<call> src proc args) (and (primitive-ref? proc) (make-primcall src (primitive-ref-name proc) args))) diff --git a/test-suite/tests/tree-il.test b/test-suite/tests/tree-il.test index 4dbe310..9ce91e7 100644 --- a/test-suite/tests/tree-il.test +++ b/test-suite/tests/tree-il.test @@ -1598,7 +1598,15 @@ (lambda _ (lambda-case (((x y) #f #f #f () (_ _)) - _))))) + _)))) + + (pass-if-peval + ((@ (guile) car) '(1 2)) + (const 1)) + + (pass-if-peval + ((@@ (guile) car) '(1 2)) + (const 1))) -- 1.7.9.1 l...@gnu.org (Ludovic Courtès) writes: > Hi BT, > > BT Templeton <b...@hcoop.net> skribis: > >> * module/language/tree-il/primitives.scm (resolve-primitives!): Resolve >> public module-refs to primitives. > > What about resolving private module-refs too? Here’s the motivation: That was already supported; this patch just additionally adds support for public refs. > Also, here’s a test case for you to add in tree-il.test: ;-) > > (pass-if-peval resolve-primitives > ;; Module-refs that resolve to primitives are opened. > (apply (@@ (guile) car) (const (1 2))) > (const 1)) > > Could you provide an updated patch? Yes, see above for a version that includes tests. -- Inteligenta persono lernas la lingvon Esperanton rapide kaj facile. Esperanto estas moderna, kultura lingvo por la mondo. Simpla, fleksebla, belsona, Esperanto estas la praktika solvo de la problemo de universala interkompreno. Lernu la interlingvon Esperanton!