chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-hackers] [PATCH] fix explicit re-export of syntax in module wit


From: Felix
Subject: [Chicken-hackers] [PATCH] fix explicit re-export of syntax in module with "*" export list
Date: Wed, 01 Aug 2012 16:21:06 +0200 (CEST)

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. This patch fixes #882.


cheers,
felix
>From f79b85653ec19766c942a3df5b0bee3f57f001a6 Mon Sep 17 00:00:00 2001
From: felix <address@hidden>
Date: Mon, 30 Jul 2012 22:08:02 +0200
Subject: [PATCH] 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.
---
 modules.scm            |   16 ++++++++++++----
 tests/module-tests.scm |   22 ++++++++++++++++++++++
 2 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/modules.scm b/modules.scm
index 6cea21e..078da0d 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 4314f68..928046a 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")
 
-- 
1.7.0.4


reply via email to

[Prev in Thread] Current Thread [Next in Thread]