bug-guile
[Top][All Lists]
Advanced

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

[PATCH] Use module identity to filter for existing modules


From: Andreas Rottmann
Subject: [PATCH] Use module identity to filter for existing modules
Date: Wed, 02 Mar 2011 17:54:58 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Hi!

As discussed on IRC, here is a fix that makes R6RS's `import' work again
when importing multiple times from the same library.  See the patch
header for details.

From: Andreas Rottmann <address@hidden>
Subject: Use module identity to filter for existing modules

This fixes a problem with R6RS's `import' in particuliar: when importing
a subset of a library/module, the interface created for that purpose
inherits the name of the module it is derived from.  The low-level
primitives that are used for importing would then disregard earlier
imports from the same module.

An example for this bug can be seen with the following library
definition:

(library (test-guile2)
  (export foo)
  (import (only (rnrs base) define)
          (only (rnrs base) error))

  (define (foo . args)
    #t))

In the above, the import of `define' would be disregarded when `error'
is imported, thus leading to a syntax error, since `(foo . args)' is
treated as an application, since the binding of `define' would be not
present.


* module/ice-9/boot-9.scm (module-use!): Remove the filtering of the
  existing imports of the module by name; a check for identity is
  already done beforehand.
  (module-use-interfaces!): Filter the existing imports by identity
  instead of filtering them by their names.

---
 module/ice-9/boot-9.scm |   12 +++---------
 1 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm
index 9f621d9..fbad99b 100644
--- a/module/ice-9/boot-9.scm
+++ b/module/ice-9/boot-9.scm
@@ -1987,13 +1987,8 @@ VALUE."
         ;; Newly used modules must be appended rather than consed, so that
         ;; `module-variable' traverses the use list starting from the first
         ;; used module.
-        (set-module-uses! module
-                          (append (filter (lambda (m)
-                                            (not
-                                             (equal? (module-name m)
-                                                     (module-name interface))))
-                                          (module-uses module))
-                                  (list interface)))
+        (set-module-uses! module (append (module-uses module)
+                                         (list interface)))
         (hash-clear! (module-import-obarray module))
         (module-modified module))))
 
@@ -2004,8 +1999,7 @@ VALUE."
 (define (module-use-interfaces! module interfaces)
   (let ((prev (filter (lambda (used)
                         (and-map (lambda (iface)
-                                   (not (equal? (module-name used)
-                                                (module-name iface))))
+                                   (not (eq? used iface)))
                                  interfaces))
                       (module-uses module))))
     (set-module-uses! module
-- 
tg: (58b1db5..) t/fix-module-use (depends on: stable-2.0)
Regards, Rotty
-- 
Andreas Rottmann -- <http://rotty.yi.org/>

reply via email to

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