1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-13 15:10:34 +02:00

Fix default-duplicate-binding-handlers for compilation

* module/ice-9/boot-9.scm (define-module*): Capture value of
  `default-duplicate-binding-procedures' when the module is created.
  Fixes #20093.
This commit is contained in:
Andy Wingo 2016-06-23 17:08:38 +02:00
parent 1d72d46951
commit 04d87db927

View file

@ -2827,7 +2827,7 @@ written into the port is returned."
;; sure to update "modules.c" as well. ;; sure to update "modules.c" as well.
(define* (define-module* name (define* (define-module* name
#:key filename pure version (duplicates '()) #:key filename pure version (duplicates #f)
(imports '()) (exports '()) (replacements '()) (imports '()) (exports '()) (replacements '())
(re-exports '()) (autoloads '()) transformer) (re-exports '()) (autoloads '()) transformer)
(define (list-of pred l) (define (list-of pred l)
@ -2869,35 +2869,36 @@ written into the port is returned."
(let ((imports (resolve-imports imports))) (let ((imports (resolve-imports imports)))
(call-with-deferred-observers (call-with-deferred-observers
(lambda () (lambda ()
(if (pair? imports) (unless (list-of valid-export? exports)
(module-use-interfaces! module imports)) (error "expected exports to be a list of symbols or symbol pairs"))
(if (list-of valid-export? exports) (unless (list-of valid-export? replacements)
(if (pair? exports) (error "expected replacements to be a list of symbols or symbol pairs"))
(module-export! module exports)) (unless (list-of valid-export? re-exports)
(error "expected exports to be a list of symbols or symbol pairs")) (error "expected re-exports to be a list of symbols or symbol pairs"))
(if (list-of valid-export? replacements) (unless (null? imports)
(if (pair? replacements) (module-use-interfaces! module imports))
(module-replace! module replacements)) (module-export! module exports)
(error "expected replacements to be a list of symbols or symbol pairs")) (module-replace! module replacements)
(if (list-of valid-export? re-exports) (module-re-export! module re-exports)
(if (pair? re-exports) ;; FIXME: Avoid use of `apply'.
(module-re-export! module re-exports)) (apply module-autoload! module autoloads)
(error "expected re-exports to be a list of symbols or symbol pairs")) ;; Capture the value of `default-duplicate-binding-procedures'
;; FIXME ;; that is current when the module is defined, unless the user
(if (not (null? autoloads)) ;; specfies a #:duplicates set explicitly. Otherwise if we
(apply module-autoload! module autoloads)) ;; leave it unset, we would delegate the duplicates-handling
;; Wait until modules have been loaded to resolve duplicates ;; behavior to whatever default the user has set at whatever
;; handlers. ;; time in the future we first use an imported binding.
(if (pair? duplicates) (let ((handlers (if duplicates
(let ((handlers (lookup-duplicates-handlers duplicates))) (lookup-duplicates-handlers duplicates)
(set-module-duplicates-handlers! module handlers)))))) (default-duplicate-binding-procedures))))
(set-module-duplicates-handlers! module handlers)))))
(if transformer (when transformer
(if (and (pair? transformer) (list-of symbol? transformer)) (unless (and (pair? transformer) (list-of symbol? transformer))
(let ((iface (resolve-interface transformer)) (error "expected transformer to be a module name" transformer))
(sym (car (last-pair transformer)))) (let ((iface (resolve-interface transformer))
(set-module-transformer! module (module-ref iface sym))) (sym (car (last-pair transformer))))
(error "expected transformer to be a module name" transformer))) (set-module-transformer! module (module-ref iface sym))))
(run-hook module-defined-hook module) (run-hook module-defined-hook module)
module)) module))