~ chicken-core (chicken-5) a01a9da3e4832791c70a062f4a1534909fff1c77
commit a01a9da3e4832791c70a062f4a1534909fff1c77 Author: felix <felix@call-with-current-continuation.org> AuthorDate: Mon Jul 30 22:08:02 2012 +0200 Commit: Christian Kellermann <ckeen@pestilenz.org> CommitDate: Mon Aug 6 22:01:45 2012 +0200 Fix for star-export with explicit re-export of syntax (#882) In a module with a "*" export list that explicitly re-exports syntax (via "export") imported from another module, the export is currently not externally visible. The reason for this is that the re-exported syntax does not appear in the "sexports" slot of the module record from the module that does the export. It is also not in the list of syntax definition (since it is not defined in that module). To make this work, "export" has to check for a module with "*" export-list and add the information of the rexported syntax found in the current macro-environment to the "sexports" slot. Finalization of the module will merge syntax definitions found in the definition-list and in sexports to make the reexport work with import-libraries. Part of this patch is from sjamaan, the problem was reported by megane. Signed-off-by: Christian Kellermann <ckeen@pestilenz.org> diff --git a/modules.scm b/modules.scm index 6cea21e9..078da0d0 100644 --- a/modules.scm +++ b/modules.scm @@ -159,9 +159,17 @@ (define (##sys#add-to-export-list mod exps) (let ((xl (module-export-list mod))) (if (eq? xl #t) - (let ((el (module-exist-list mod))) - (set-module-exist-list! - mod (append el exps))) + (let ((el (module-exist-list mod)) + (me (##sys#macro-environment)) + (sexps '())) + (for-each + (lambda (exp) + (cond ((assq exp me) => + (lambda (a) + (set! sexps (cons a sexps)))))) + exps) + (set-module-sexports! mod (append sexps (module-sexports mod))) + (set-module-exist-list! mod (append el exps))) (set-module-export-list! mod (append xl exps))))) @@ -437,7 +445,7 @@ (module-defined-syntax-list mod))) (sexports (if (eq? #t explist) - sdlist + (merge-se (module-sexports mod) sdlist) (let loop ((me (##sys#macro-environment))) (cond ((null? me) '()) ((##sys#find-export (caar me) mod #f) diff --git a/tests/module-tests.scm b/tests/module-tests.scm index 4314f689..928046a0 100644 --- a/tests/module-tests.scm +++ b/tests/module-tests.scm @@ -276,5 +276,27 @@ c/bar) ;; <- Error: unbound variable: c/bar 2) +;; somewhat related, but with syntax (#882, found by megane): + +(module m29 * + (import chicken scheme) + (define-syntax m29-baz + (lambda _ + ''foo))) + +(module m30 * + (import chicken scheme) + (import m29) + (export m29-baz)) + +(test-equal + "star-export with explicit re-export of syntax" + (module m31 () + (import scheme chicken) + (import m30) + (m29-baz)) + 'foo) + + (test-end "modules")Trap