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

From: David Pirotte <[email-masked]>
Date: Mon, 3 May 2021 01:26:41 -0300

Hello,

> ...
> (define-module (a)
>   #:use-module (srfi srfi-1))

> (eval-when (expand load eval)
>   (module-use! (module-public-interface (current-module))
>                (resolve-interface '(srfi srfi-1))))
> ...

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.

Here is a example, so one can reproduce and maybe give us some
hints:

;;; module (a) starts here
(define-module (foo)
  #:use-module (srfi srfi-1))

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

(for-each display '(1 2 3 4))
(newline)
;;; module (foo) ends here

;;; file bar.scm starts here - not a module, just a file
(use-modules (foo))

#;(eval-when (expand load eval)
  (default-duplicate-binding-handler
    '(replace last)))

(for-each display '(5 6 7 8))
(newline)

;; drop the two above module/file somwhere

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

;; you should see that there is no warning 'from (foo)', but two
;; warnings

	WARNING: (guile-user): imported module (a) overrides core
	binding `for-each'

;; 'from the bar.scm file (one when it compiles, one when it 'runs' ...
;; if you start a new session, then there should be one warning only ...

Now, if we uncomment the eval-when in bar.scm and try again, all is
fine

But i wish the module-use! interface/internals would be enhanced so
that it does the same thing for module-use! then what is done simply
using #:use-module... and allow us to keep warn-override-core and warn
in the default-duplicate-binding-handler list ... not sure i made
myself clear, but trying :)

David