fix order of importing modules and resolving duplicates handlers
authorAndy Wingo <wingo@pobox.com>
Thu, 18 Aug 2011 10:56:14 +0000 (12:56 +0200)
committerAndy Wingo <wingo@pobox.com>
Thu, 18 Aug 2011 10:56:14 +0000 (12:56 +0200)
* module/ice-9/boot-9.scm (define-module*): Resolve duplicates handlers
  only after importing modules.  Fixes a bug in which a module with
  #:use-module (oop goops) but whose merge-generics handler got resolved
  to noop instead of the real merge-generics handler.  I can't think of
  an easy way to test this, though.

  Thanks to David Pirotte for the report!

module/ice-9/boot-9.scm

index 8a938ec..b7e9f7f 100644 (file)
@@ -2656,10 +2656,6 @@ VALUE."
               (error "expected list of integers for version"))
           (set-module-version! module version)
           (set-module-version! (module-public-interface module) version)))
-    (if (pair? duplicates)
-        (let ((handlers (lookup-duplicates-handlers duplicates)))
-          (set-module-duplicates-handlers! module handlers)))
-
     (let ((imports (resolve-imports imports)))
       (call-with-deferred-observers
        (lambda ()
@@ -2679,7 +2675,12 @@ VALUE."
              (error "expected re-exports to be a list of symbols or symbol pairs"))
          ;; FIXME
          (if (not (null? autoloads))
-             (apply module-autoload! module autoloads)))))
+             (apply module-autoload! module autoloads))
+         ;; Wait until modules have been loaded to resolve duplicates
+         ;; handlers.
+         (if (pair? duplicates)
+             (let ((handlers (lookup-duplicates-handlers duplicates)))
+               (set-module-duplicates-handlers! module handlers))))))
 
     (if transformer
         (if (and (pair? transformer) (list-of symbol? transformer))