Subject: bug#47084: Guile 3.0 - The module-use! 'target' functionality is broken

From: David Pirotte <[email-masked]>
Date: Tue, 4 May 2021 01:37:33 -0300

Hello,

> ...
> Commit 19f38a38fde7da5fbcf29d0ebc4574e993210110 fixes the
> bug, many thanks.

> Now, I have a question related to 'new' warnings though - I say 'new'
> because there are no warnings in 2.2 - for which I don't see how one
> can resolve those, unless mute them all by calling
> default-duplicate-binding-handler and remove warn-override-core
> and warn from the default list.

The proper way to stop these warnings is to add a
#:re-export-and-replace clause to the module definition of the module
that calls module-use! - I didn't think I had to do this because we
didn't have to using 2.2 (nor #:re-export nor #:replace, within the
context of module-use! that is, and the #:re-export-and-replace clause
is new to 3.0) - like this:

;;; module (a) starts here
(define-module (foo)
  #:use-module (srfi srfi-1))
  #:re-export-and-replace (for-each))

(eval-when (expand load eval)
  (module-use! (module-public-interface (current-module))
               (resolve-interface '(srfi srfi-1))))
;;; module (foo) ends here

Now the (bar) module or bar.scm file example file may skip the call to
default-duplicate-binding-handler:

;;; file bar.scm starts here
(use-modules (foo))
    
(for-each display '(5 6 7 8))
(newline)
;; file bar.scm stops here 

;; drop the two above module/file somwhere

;;; now, fire geiser and
(add-to-load-path "/your/path")
(load "/your/path/bar.scm")

;; you shouldn't see any warnings anymore...

David