From b0ae9ca6ffad6cfe70c50cc062f6f655bc995b10 Mon Sep 17 00:00:00 2001 From: Peter Bex Date: Fri, 13 Jul 2018 21:49:20 +0200 Subject: [PATCH] Scan module definition for extra exports following interface usage This was pointed out by Martin Schneeweis, fix suggested by megane. --- NEWS | 2 ++ modules.scm | 2 +- tests/functor-tests.scm | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index df0efd7f..b758cf31 100644 --- a/NEWS +++ b/NEWS @@ -107,6 +107,8 @@ in favor of "import" and "import-for-syntax" to reduce confusion. - Module imports are now lexically scoped: identifiers provided by an (import ...) inside (let ...) won't be visible outside that let. + - Modules implementing an interface can now correctly export extra + identifiers (bug reported by Martin Schneeweis, fix by "megane"). - Syntax expander - Removed support for (define-syntax (foo e r c) ...), which was diff --git a/modules.scm b/modules.scm index 73e89474..b0cdce59 100644 --- a/modules.scm +++ b/modules.scm @@ -803,7 +803,7 @@ (cons (cdr x) (loop (cdr xps)))) ; currently not used ((eq? #:interface (car x)) (if (and (pair? (cdr x)) (symbol? (cadr x))) - (iface (cadr x)) + (append (iface (cadr x)) (loop (cdr xps))) (err "invalid interface specification" x exps))) (else (let loop2 ((lst x)) diff --git a/tests/functor-tests.scm b/tests/functor-tests.scm index 6771802f..aa3aeab9 100644 --- a/tests/functor-tests.scm +++ b/tests/functor-tests.scm @@ -236,6 +236,26 @@ '#(99)) +;; Module implementing functor plus more exports did not expose the +;; additional exports (pointed out by Martin Schneeweis, patch +;; suggested by megane) + +(define-interface iface-a (some-a)) + +(module iface-a-plus-extra ((interface: iface-a) + extra-a) + (import scheme (chicken base)) + (define extra-a 'extra-a) + (define some-a 'some-a)) + +(test-equal + "Functor with extra exports" + (module m6 () + (import iface-a-plus-extra scheme) + (list extra-a some-a)) + '(extra-a some-a)) + + ;; (test-end) -- 2.11.0