GNU bug report logs - #20093
master: setting merge-generics duplicate-binding-handler @ expand time raises an error

Previous Next

Package: guile;

Reported by: David Pirotte <david <at> altosw.be>

Date: Thu, 12 Mar 2015 03:19:01 UTC

Severity: normal

Done: Andy Wingo <wingo <at> pobox.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 20093 in the body.
You can then email your comments to 20093 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#20093; Package guile. (Thu, 12 Mar 2015 03:19:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to David Pirotte <david <at> altosw.be>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Thu, 12 Mar 2015 03:19:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: David Pirotte <david <at> altosw.be>
To: <bug-guile <at> gnu.org>
Subject: master: setting merge-generics duplicate-binding-handler @ expand
 time raises an error
Date: Thu, 12 Mar 2015 00:17:18 -0300
[Message part 1 (text/plain, inline)]
Hello guilers,
Hi Andy,

Following our brief chat on irc, yesterday, here is he bug I was referring to:

	GNU Guile 2.1.0.322-eb3d6

	setting merge-generics duplicate-binding-handler @ expand time raises an
	error.

a) here is a short test case:

--8<---------------cut here---------------start------------->8---
#! /bin/sh
# -*- mode: scheme; coding: utf-8 -*-
exec guile -e main -s $0 "$@"
!#

(eval-when (expand load eval)
  (use-modules (oop goops))
  (default-duplicate-binding-handler
    '(merge-generics replace warn-override-core warn last)))

(define (main args)
  (display "hello\n"))
--8<---------------cut here---------------start------------->8---

=>

david <at> capac:~/alto/projects/guile-tests/2.2/goops/duplicate-binding-handler 76 $ ./hello 
;;; note: source file /usr/alto/projects/guile-tests/2.2/goops/duplicate-binding-handler/./hello
;;;       newer than compiled /home/david/.cache/guile/ccache/2.2-LE-8-3.6/usr/alto/projects/guile-tests/2.2/goops/duplicate-binding-handler/hello.go
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;       or pass the --no-auto-compile argument to disable.
;;; compiling /usr/alto/projects/guile-tests/2.2/goops/duplicate-binding-handler/./hello
;;; WARNING: compilation of /usr/alto/projects/guile-tests/2.2/goops/duplicate-binding-handler/./hello failed:
;;; ERROR: No applicable method for #<<generic> merge-generics (3)> in call Error while printing exception.
hello!


b) here is how it propagates, 'just' trying to import 2 gnome modules:

--8<---------------cut here---------------start------------->8---
#! /bin/sh
# -*- mode: scheme; coding: utf-8 -*-
exec guile -e main -s $0 "$@"
!#

(eval-when (expand load eval)
  (use-modules (oop goops))
  (default-duplicate-binding-handler
    '(merge-generics replace warn-override-core warn last)))

(use-modules (gnome-2)
             (gnome gobject)
             (gnome glib))

(define (main args)
  (display "hello!\n"))
--8<---------------cut here---------------start------------->8---

=>

david <at> capac:~/alto/projects/guile-tests/2.2/goops/duplicate-binding-handler 40 $ ./hello
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;       or pass the --no-auto-compile argument to disable.
;;; compiling /usr/alto/projects/guile-tests/2.2/goops/duplicate-binding-handler/./hello
;;; WARNING: compilation of /usr/alto/projects/guile-tests/2.2/goops/duplicate-binding-handler/./hello failed:
;;; ERROR: No applicable method for #<<generic> merge-generics (3)> in call Error while printing exception.
Backtrace:
In ice-9/boot-9.scm:
3275: 19 [try-module-autoload _ _]
2611: 18 [save-module-excursion #<program b6fe10 7f8a1b537984>]
3295: 17 [#<program b6fe10 7f8a1b537984>]
In unknown file:
   ?: 16 [primitive-load-path "gnome/gw/glib" #<program cb7120 7f8a1b537acc>]
In gnome/gw/glib.scm:
  15: 15 [#<unspecified>]
In unknown file:
   ?: 14 [load-extension "libgw-guile-gnome-glib" "gw_init_wrapset_gnome_glib"]
In ice-9/boot-9.scm:
2999: 13 [#<variable ac1fd0 value: #<program 7f8a1b57ae68 7f8a1b539380>> # _ _ ...]
3275: 12 [try-module-autoload _ _]
2611: 11 [save-module-excursion #<program b6fc90 7f8a1b537984>]
3295: 10 [#<program b6fc90 7f8a1b537984>]
In unknown file:
   ?: 9 [primitive-load-path "gnome/gw/generics" #<program d01a60 7f8a1b537acc>]
In gnome/gw/generics.scm:
  35: 8 [#f]
In ice-9/boot-9.scm:
3136: 7 [define-module* _ #:filename _ #:pure _ #:version _ #:duplicates ...]
3074: 6 [resolve-interface (gnome gobject generics) #:select ...]
2999: 5 [#<variable ac1fd0 value: #<program 7f8a1b57ae68 7f8a1b539380>> # _ _ ...]
3275: 4 [try-module-autoload _ _]
2611: 3 [save-module-excursion #<program b6fc30 7f8a1b537984>]
3295: 2 [#<program b6fc30 7f8a1b537984>]
In unknown file:
   ?: 1 [primitive-load-path "gnome/gobject/generics" ...]
In gnome/gobject/generics.scm:
 130: 0 [()]

gnome/gobject/generics.scm:130:0: In procedure ():
gnome/gobject/generics.scm:130:0: In procedure module-lookup: Unbound variable: <gobject>
david <at> capac:~/alto/projects/guile-tests/2.2/goops/duplicate-binding-handler 41 $ 


Cheers,
David
[Message part 2 (application/pgp-signature, inline)]

Reply sent to Andy Wingo <wingo <at> pobox.com>:
You have taken responsibility. (Thu, 23 Jun 2016 16:01:01 GMT) Full text and rfc822 format available.

Notification sent to David Pirotte <david <at> altosw.be>:
bug acknowledged by developer. (Thu, 23 Jun 2016 16:01:02 GMT) Full text and rfc822 format available.

Message #10 received at 20093-done <at> debbugs.gnu.org (full text, mbox):

From: Andy Wingo <wingo <at> pobox.com>
To: David Pirotte <david <at> altosw.be>
Cc: 20093-done <at> debbugs.gnu.org
Subject: Re: bug#20093: master: setting merge-generics
 duplicate-binding-handler @ expand time raises an error
Date: Thu, 23 Jun 2016 18:00:27 +0200
Hi,

This was interesting -- turned out that GOOPS imports `map' from (srfi
srfi-1), and it's also there from (guile-user).  SRFI-1 specified it via
#:replace so all is well, no warnings.  However merge-generics is itself
a generic which needs `map' to dispatch over its types (at first) and
then that recurses, leading to badness.

But, you say, I only specified the duplicates handler after loading
goops!  Well indeed, but if a module didn't specify #:duplicates, its
duplicates handling was implicitly dynamically scoped to whatever the
current default-duplicates-handlers were.  That seems bogus to me: the
module declares its imports and exports and a lack of a declaration of
#:duplicates indicates that the module is implicitly specifying the
duplicate handlers that are described in the manual.

In master I have changed the `default-duplicate-binding-handler' to
simply access the handlers for the current module, as that seems to be
the correct thing.  Let me know how it goes!  Closing as done but let's
follow up :)

Andy

On Thu 12 Mar 2015 04:17, David Pirotte <david <at> altosw.be> writes:

> Hello guilers,
> Hi Andy,
>
> Following our brief chat on irc, yesterday, here is he bug I was referring to:
>
> 	GNU Guile 2.1.0.322-eb3d6
>
> 	setting merge-generics duplicate-binding-handler @ expand time raises an
> 	error.
>
> a) here is a short test case:
>
> #! /bin/sh
> # -*- mode: scheme; coding: utf-8 -*-
> exec guile -e main -s $0 "$@"
> !#
>
> (eval-when (expand load eval)
>   (use-modules (oop goops))
>   (default-duplicate-binding-handler
>     '(merge-generics replace warn-override-core warn last)))
>
> (define (main args)
>   (display "hello\n"))
>
> =>
>
> david <at> capac:~/alto/projects/guile-tests/2.2/goops/duplicate-binding-handler 76 $ ./hello 
> ;;; note: source file /usr/alto/projects/guile-tests/2.2/goops/duplicate-binding-handler/./hello
> ;;;       newer than compiled /home/david/.cache/guile/ccache/2.2-LE-8-3.6/usr/alto/projects/guile-tests/2.2/goops/duplicate-binding-handler/hello.go
> ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
> ;;;       or pass the --no-auto-compile argument to disable.
> ;;; compiling /usr/alto/projects/guile-tests/2.2/goops/duplicate-binding-handler/./hello
> ;;; WARNING: compilation of /usr/alto/projects/guile-tests/2.2/goops/duplicate-binding-handler/./hello failed:
> ;;; ERROR: No applicable method for #<<generic> merge-generics (3)> in call Error while printing exception.
> hello!
>
>
> b) here is how it propagates, 'just' trying to import 2 gnome modules:
>
> #! /bin/sh
> # -*- mode: scheme; coding: utf-8 -*-
> exec guile -e main -s $0 "$@"
> !#
>
> (eval-when (expand load eval)
>   (use-modules (oop goops))
>   (default-duplicate-binding-handler
>     '(merge-generics replace warn-override-core warn last)))
>
> (use-modules (gnome-2)
>              (gnome gobject)
>              (gnome glib))
>
> (define (main args)
>   (display "hello!\n"))
>
> =>
>
> david <at> capac:~/alto/projects/guile-tests/2.2/goops/duplicate-binding-handler 40 $ ./hello
> ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
> ;;;       or pass the --no-auto-compile argument to disable.
> ;;; compiling /usr/alto/projects/guile-tests/2.2/goops/duplicate-binding-handler/./hello
> ;;; WARNING: compilation of /usr/alto/projects/guile-tests/2.2/goops/duplicate-binding-handler/./hello failed:
> ;;; ERROR: No applicable method for #<<generic> merge-generics (3)> in call Error while printing exception.
> Backtrace:
> In ice-9/boot-9.scm:
> 3275: 19 [try-module-autoload _ _]
> 2611: 18 [save-module-excursion #<program b6fe10 7f8a1b537984>]
> 3295: 17 [#<program b6fe10 7f8a1b537984>]
> In unknown file:
>    ?: 16 [primitive-load-path "gnome/gw/glib" #<program cb7120 7f8a1b537acc>]
> In gnome/gw/glib.scm:
>   15: 15 [#<unspecified>]
> In unknown file:
>    ?: 14 [load-extension "libgw-guile-gnome-glib" "gw_init_wrapset_gnome_glib"]
> In ice-9/boot-9.scm:
> 2999: 13 [#<variable ac1fd0 value: #<program 7f8a1b57ae68 7f8a1b539380>> # _ _ ...]
> 3275: 12 [try-module-autoload _ _]
> 2611: 11 [save-module-excursion #<program b6fc90 7f8a1b537984>]
> 3295: 10 [#<program b6fc90 7f8a1b537984>]
> In unknown file:
>    ?: 9 [primitive-load-path "gnome/gw/generics" #<program d01a60 7f8a1b537acc>]
> In gnome/gw/generics.scm:
>   35: 8 [#f]
> In ice-9/boot-9.scm:
> 3136: 7 [define-module* _ #:filename _ #:pure _ #:version _ #:duplicates ...]
> 3074: 6 [resolve-interface (gnome gobject generics) #:select ...]
> 2999: 5 [#<variable ac1fd0 value: #<program 7f8a1b57ae68 7f8a1b539380>> # _ _ ...]
> 3275: 4 [try-module-autoload _ _]
> 2611: 3 [save-module-excursion #<program b6fc30 7f8a1b537984>]
> 3295: 2 [#<program b6fc30 7f8a1b537984>]
> In unknown file:
>    ?: 1 [primitive-load-path "gnome/gobject/generics" ...]
> In gnome/gobject/generics.scm:
>  130: 0 [()]
>
> gnome/gobject/generics.scm:130:0: In procedure ():
> gnome/gobject/generics.scm:130:0: In procedure module-lookup: Unbound variable: <gobject>
> david <at> capac:~/alto/projects/guile-tests/2.2/goops/duplicate-binding-handler 41 $ 
>
>
> Cheers,
> David




Information forwarded to bug-guile <at> gnu.org:
bug#20093; Package guile. (Sun, 03 Jul 2016 04:59:02 GMT) Full text and rfc822 format available.

Message #13 received at 20093-done <at> debbugs.gnu.org (full text, mbox):

From: David Pirotte <david <at> altosw.be>
To: Andy Wingo <wingo <at> pobox.com>
Cc: 20093-done <at> debbugs.gnu.org
Subject: Re: bug#20093: master: setting merge-generics
 duplicate-binding-handler @ expand time raises an error
Date: Sun, 3 Jul 2016 01:57:49 -0300
[Message part 1 (text/plain, inline)]
Hi Andy,

> This was interesting -- turned out that GOOPS imports `map' from (srfi
> srfi-1), and it's also there from (guile-user).  SRFI-1 specified it via
> #:replace so all is well, no warnings.  However merge-generics is itself
> a generic which needs `map' to dispatch over its types (at first) and
> then that recurses, leading to badness.

Thanks, it fixed the bug wrt the example of the original message, but it seems it
introduced a new bug, see below.

> But, you say, I only specified the duplicates handler after loading
> goops!  Well indeed, but if a module didn't specify #:duplicates, its
> duplicates handling was implicitly dynamically scoped to whatever the
> current default-duplicates-handlers were.  That seems bogus to me: the
> module declares its imports and exports and a lack of a declaration of
> #:duplicates indicates that the module is implicitly specifying the
> duplicate handlers that are described in the manual.

> In master I have changed the `default-duplicate-binding-handler' to
> simply access the handlers for the current module, as that seems to be
> the correct thing.  Let me know how it goes!  Closing as done but let's
> follow up :)

This is a big problem for me, so I partially locally reverted that part of
the patch, plus, I patch guild so it does this before anything else:

	(eval-when (expand load eval)
	  (use-modules (oop goops))
	  (default-duplicate-binding-handler
	    '(merge-generics replace warn-override-core warn last)))

This worked well with guile-2.0 [guild patched the same way I mean], but raises a
bug using guild from 2.2, that I can reproduce even not reverting anything from your
fix:

	if you patch guild the same way, just to try, then try to compile any file that
	does even not use goops, it raises the same error

As an example, let's create a reexport.scm [based on guile-gnome
glib/gnome/gw/support/modules.scm]

;; reexport.scm starts here
(define-module (reexport)
  #:export (re-export-public-interface))

(define-macro (re-export-public-interface . args)
  "Re-export the public interface of a module or modules. Invoked as
@code{(re-export-public-interface (mod1) (mod2)...)}."
  (if (null? args)
      '(if #f #f)
      `(begin
	 ,@(map (lambda (mod)
		  (or (list? mod)
		      (error "Invalid module specification" mod))
		  `(module-use! (module-public-interface (current-module))
				(resolve-interface ',mod)))
		args))))
;; reexport.scm ends here

Then let's try to compile it using the patched guild as mentioned above:

david <at> capac:~/gnu/grip/git/grip 5 $ which guild
/opt2/bin/guild
david <at> capac:~/gnu/grip/git/grip 6 $ guild compile reexport.scm 
;;; note: source file /opt2/bin/guild
;;;       newer than compiled /home/david/.cache/guile/ccache/2.2-LE-8-3.9/opt2/bin/guild.go
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;       or pass the --no-auto-compile argument to disable.
;;; compiling /opt2/bin/guild
;;; WARNING: compilation of /opt2/bin/guild failed:
;;; ERROR: No applicable method for #<<generic> merge-generics (3)> in call (merge-generics #<directory (guild) 266d750> format #<interface (guile) 2645ea0> #<procedure 26f8920 at ice-9/format.scm:1609:9 (destination format-string . args) | (deprecated-format-string-only)> #<autoload (ice-9 format) 28fc000> #<procedure 26f8920 at ice-9/format.scm:1609:9 (destination format-string . args) | (deprecated-format-string-only)> #f #f)
Backtrace:
In ice-9/eval.scm:
   710:20 19 (primitive-eval (define (main args) (if (# (# #)) #) #))
In ice-9/psyntax.scm:
  1199:22 18 (expand-top-sequence ((define (main args) (if (…) …) …)) …)
In ice-9/boot-9.scm:
   224:17 17 (map1 (#<procedure 2926550 at ice-9/psyntax.scm:1116:3…>))
In ice-9/psyntax.scm:
  1374:12 16 (_)
  1754:11 15 (lp (#(syntax-object (if (defined? (quote #)) #) # …) …) …)
  1644:45 14 (parse _ _ _ _ _ _ _)
In ice-9/boot-9.scm:
   224:17 13 (map1 (((("placeholder" placeholder) ("…" . #) …) . #) …))
In ice-9/psyntax.scm:
  1374:12 12 (_ _ _)
  1449:23 11 (_ _ _)
In ice-9/boot-9.scm:
   224:29 10 (map1 ((quote system-error) (lambda () (setlocale …)) #))
   224:29  9 (map1 ((lambda () (setlocale LC_ALL "")) (lambda # #)))
   224:17  8 (map1 ((lambda args (format (current-error-port) # #))))
In ice-9/psyntax.scm:
  1754:11  7 (lp ((format (current-error-port) "warning: failed…" …)) …)
  1577:33  6 (parse (((("placeholder" placeholder) ("…" . #) …) . #)) …)
  1298:27  5 (syntax-type (format (current-error-port) "warning:…" …) …)
  1282:39  4 (syntax-type format (("placeholder" placeholder) # # …) …)
   302:24  3 (resolve-identifier _ _ (("placeholder" placeholder) …) …)
In unknown file:
           2 (module-variable #<directory (guild) 266d750> format)
In oop/goops.scm:
   1437:4  1 (cache-miss #<directory (guild) 266d750> format #<inte…> …)
In unknown file:
           0 (scm-error goops-error #f "No applicable method for ~S…" …)

ERROR: In procedure scm-error:
ERROR: No applicable method for #<<generic> merge-generics (3)> in call (merge-generics #<directory (guild) 266d750> format #<interface (guile) 2645ea0> #<procedure 26f8920 at ice-9/format.scm:1609:9 (destination format-string . args) | (deprecated-format-string-only)> #<interface (ice-9 format) 26f5b40> #<procedure 26f8920 at ice-9/format.scm:1609:9 (destination format-string . args) | (deprecated-format-string-only)> #f #f)
david <at> capac:~/gnu/grip/git/grip 7 $ 


NOW, let's ask guild to use --no-auto-compile

#!/bin/sh
# -*- scheme -*-
exec ${GUILE:-/opt2/bin/guile} --no-auto-compile -e '(@@ (guild) main)' -s "$0" "$@"
!#
... ...
 And try again:

david <at> capac:~/gnu/grip/git/grip 8 $ guild compile reexport.scm 
;;; note: source file /opt2/bin/guild
;;;       newer than compiled /home/david/.cache/guile/ccache/2.2-LE-8-3.9/opt2/bin/guild.go
Backtrace:
In ice-9/eval.scm:
   710:20 19 (primitive-eval (define (main args) (if (# (# #)) #) #))
In ice-9/psyntax.scm:
  1199:22 18 (expand-top-sequence ((define (main args) (if (…) …) …)) …)
In ice-9/boot-9.scm:
   224:17 17 (map1 (#<procedure 1ac7640 at ice-9/psyntax.scm:1116:3…>))
In ice-9/psyntax.scm:
  1374:12 16 (_)
  1754:11 15 (lp (#(syntax-object (if (defined? (quote #)) #) # …) …) …)
  1644:45 14 (parse _ _ _ _ _ _ _)
In ice-9/boot-9.scm:
   224:17 13 (map1 (((("placeholder" placeholder) ("…" . #) …) . #) …))
In ice-9/psyntax.scm:
  1374:12 12 (_ _ _)
  1449:23 11 (_ _ _)
In ice-9/boot-9.scm:
   224:29 10 (map1 ((quote system-error) (lambda () (setlocale …)) #))
   224:29  9 (map1 ((lambda () (setlocale LC_ALL "")) (lambda # #)))
   224:17  8 (map1 ((lambda args (format (current-error-port) # #))))
In ice-9/psyntax.scm:
  1754:11  7 (lp ((format (current-error-port) "warning: failed…" …)) …)
  1577:33  6 (parse (((("placeholder" placeholder) ("…" . #) …) . #)) …)
  1298:27  5 (syntax-type (format (current-error-port) "warning:…" …) …)
  1282:39  4 (syntax-type format (("placeholder" placeholder) # # …) …)
   302:24  3 (resolve-identifier _ _ (("placeholder" placeholder) …) …)
In unknown file:
           2 (module-variable #<directory (guild) 1b76750> format)
In oop/goops.scm:
   1437:4  1 (cache-miss #<directory (guild) 1b76750> format #<inte…> …)
In unknown file:
           0 (scm-error goops-error #f "No applicable method for ~S…" …)

ERROR: In procedure scm-error:
ERROR: No applicable method for #<<generic> merge-generics (3)> in call (merge-generics #<directory (guild) 1b76750> format #<interface (guile) 1b4eea0> #<procedure 1c81cc0 at ice-9/format.scm:1609:9 (destination format-string . args) | (deprecated-format-string-only)> #<autoload (ice-9 format) 1c60630> #<procedure 1c81cc0 at ice-9/format.scm:1609:9 (destination format-string . args) | (deprecated-format-string-only)> #f #f)
david <at> capac:~/gnu/grip/git/grip 9 $ 


BUT THIS Works:fine, in case it gives you come idea [it raises a warning though, is
this warning expected?]

david <at> capac:~/alto/projects/guile-tests/goops 3 $ guile
GNU Guile 2.1.3.52-8a087
Copyright (C) 1995-2016 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guile-user)> ,use (oop goops)
scheme@(guile-user)> (default-duplicate-binding-handler
    '(merge-generics replace warn-override-core warn last))

;;; warning: unknown warning type `macro-use-before-definition'
$1 = (#<<generic> merge-generics (3)> #<procedure replace (module name int1 val1 int2 val2 var val)> #<procedure warn-override-core (module name int1 val1 int2 val2 var val)> #<procedure warn (module name int1 val1 int2 val2 var val)> #<procedure last (module name int1 val1 int2 val2 var val)>)

scheme@(guile-user)> ,use (system base compile)
scheme@(guile-user)> (compile-file "/home/david/gnu/grip/git/grip/reexport.scm")
;;; warning: unknown warning type `macro-use-before-definition'
$2 = "/home/david/.cache/guile/ccache/2.2-LE-8-3.9/usr/alto/projects/gnu/grip/git/grip/reexport.scm.go"
scheme@(guile-user)> 


Sorry for the long email!
I hope you can help!

Cheers,
David

[Message part 2 (application/pgp-signature, inline)]

Information forwarded to bug-guile <at> gnu.org:
bug#20093; Package guile. (Sun, 03 Jul 2016 20:56:02 GMT) Full text and rfc822 format available.

Message #16 received at 20093 <at> debbugs.gnu.org (full text, mbox):

From: David Pirotte <david <at> altosw.be>
To: 20093 <at> debbugs.gnu.org
Subject: Fw: bug#20093: master: setting merge-generics
 duplicate-binding-handler @ expand time raises an error
Date: Sun, 3 Jul 2016 17:55:06 -0300
[Message part 1 (text/plain, inline)]
Hi Andy,

	It is only after I answered that I did spot in the close associated with
	this bug report that we should 'get further detail' answering the bug id and
	not bug-id-done, hence this 'forward'

> This was interesting -- turned out that GOOPS imports `map' from (srfi
> srfi-1), and it's also there from (guile-user).  SRFI-1 specified it via
> #:replace so all is well, no warnings.  However merge-generics is itself
> a generic which needs `map' to dispatch over its types (at first) and
> then that recurses, leading to badness.  

Thanks, it fixed the bug wrt the example of the original message, but it seems it
introduced a new bug, see below.

> But, you say, I only specified the duplicates handler after loading
> goops!  Well indeed, but if a module didn't specify #:duplicates, its
> duplicates handling was implicitly dynamically scoped to whatever the
> current default-duplicates-handlers were.  That seems bogus to me: the
> module declares its imports and exports and a lack of a declaration of
> #:duplicates indicates that the module is implicitly specifying the
> duplicate handlers that are described in the manual.  

> In master I have changed the `default-duplicate-binding-handler' to
> simply access the handlers for the current module, as that seems to be
> the correct thing.  Let me know how it goes!  Closing as done but let's
> follow up :)  

This is a big problem for me, so I partially locally reverted that part of
the patch, plus, I patch guild so it does this before anything else:

	(eval-when (expand load eval)
	  (use-modules (oop goops))
	  (default-duplicate-binding-handler
	    '(merge-generics replace warn-override-core warn last)))

This worked well with guile-2.0 [guild patched the same way I mean], but raises a
bug using guild from 2.2, that I can reproduce even not reverting anything from your
fix:

	if you patch guild the same way, just to try, then try to compile any file
	that does even not use goops, it raises the same error

As an example, let's create a reexport.scm [based on guile-gnome
glib/gnome/gw/support/modules.scm]

;; reexport.scm starts here
(define-module (reexport)
  #:export (re-export-public-interface))

(define-macro (re-export-public-interface . args)
  "Re-export the public interface of a module or modules. Invoked as
@code{(re-export-public-interface (mod1) (mod2)...)}."
  (if (null? args)
      '(if #f #f)
      `(begin
	 ,@(map (lambda (mod)
		  (or (list? mod)
		      (error "Invalid module specification" mod))
		  `(module-use! (module-public-interface (current-module))
				(resolve-interface ',mod)))
		args))))
;; reexport.scm ends here

Then let's try to compile it using the patched guild as mentioned above:

david <at> capac:~/gnu/grip/git/grip 5 $ which guild
/opt2/bin/guild
david <at> capac:~/gnu/grip/git/grip 6 $ guild compile reexport.scm 
;;; note: source file /opt2/bin/guild
;;;       newer than
compiled /home/david/.cache/guile/ccache/2.2-LE-8-3.9/opt2/bin/guild.go ;;; note:
auto-compilation is enabled, set GUILE_AUTO_COMPILE=0 ;;;       or pass the
--no-auto-compile argument to disable. ;;; compiling /opt2/bin/guild
;;; WARNING: compilation of /opt2/bin/guild failed:
;;; ERROR: No applicable method for #<<generic> merge-generics (3)> in call
(merge-generics #<directory (guild) 266d750> format #<interface (guile) 2645ea0>
#<procedure 26f8920 at ice-9/format.scm:1609:9 (destination format-string . args) |
(deprecated-format-string-only)> #<autoload (ice-9 format) 28fc000> #<procedure
26f8920 at ice-9/format.scm:1609:9 (destination format-string . args) |
(deprecated-format-string-only)> #f #f) Backtrace: In ice-9/eval.scm: 710:20 19
(primitive-eval (define (main args) (if (# (# #)) #) #)) In ice-9/psyntax.scm:
1199:22 18 (expand-top-sequence ((define (main args) (if (…) …) …)) …) In
ice-9/boot-9.scm: 224:17 17 (map1 (#<procedure 2926550 at
ice-9/psyntax.scm:1116:3…>)) In ice-9/psyntax.scm: 1374:12 16 (_)
  1754:11 15 (lp (#(syntax-object (if (defined? (quote #)) #) # …) …) …)
  1644:45 14 (parse _ _ _ _ _ _ _)
In ice-9/boot-9.scm:
   224:17 13 (map1 (((("placeholder" placeholder) ("…" . #) …) . #) …))
In ice-9/psyntax.scm:
  1374:12 12 (_ _ _)
  1449:23 11 (_ _ _)
In ice-9/boot-9.scm:
   224:29 10 (map1 ((quote system-error) (lambda () (setlocale …)) #))
   224:29  9 (map1 ((lambda () (setlocale LC_ALL "")) (lambda # #)))
   224:17  8 (map1 ((lambda args (format (current-error-port) # #))))
In ice-9/psyntax.scm:
  1754:11  7 (lp ((format (current-error-port) "warning: failed…" …)) …)
  1577:33  6 (parse (((("placeholder" placeholder) ("…" . #) …) . #)) …)
  1298:27  5 (syntax-type (format (current-error-port) "warning:…" …) …)
  1282:39  4 (syntax-type format (("placeholder" placeholder) # # …) …)
   302:24  3 (resolve-identifier _ _ (("placeholder" placeholder) …) …)
In unknown file:
           2 (module-variable #<directory (guild) 266d750> format)
In oop/goops.scm:
   1437:4  1 (cache-miss #<directory (guild) 266d750> format #<inte…> …)
In unknown file:
           0 (scm-error goops-error #f "No applicable method for ~S…" …)

ERROR: In procedure scm-error:
ERROR: No applicable method for #<<generic> merge-generics (3)> in call
(merge-generics #<directory (guild) 266d750> format #<interface (guile) 2645ea0>
#<procedure 26f8920 at ice-9/format.scm:1609:9 (destination format-string . args) |
(deprecated-format-string-only)> #<interface (ice-9 format) 26f5b40> #<procedure
26f8920 at ice-9/format.scm:1609:9 (destination format-string . args) |
(deprecated-format-string-only)> #f #f) david <at> capac:~/gnu/grip/git/grip 7 $ 


NOW, let's ask guild to use --no-auto-compile

#!/bin/sh
# -*- scheme -*-
exec ${GUILE:-/opt2/bin/guile} --no-auto-compile -e '(@@ (guild) main)' -s "$0" "$@"
!#
... ...
 And try again:

david <at> capac:~/gnu/grip/git/grip 8 $ guild compile reexport.scm 
;;; note: source file /opt2/bin/guild
;;;       newer than
compiled /home/david/.cache/guile/ccache/2.2-LE-8-3.9/opt2/bin/guild.go Backtrace:
In ice-9/eval.scm:
   710:20 19 (primitive-eval (define (main args) (if (# (# #)) #) #))
In ice-9/psyntax.scm:
  1199:22 18 (expand-top-sequence ((define (main args) (if (…) …) …)) …)
In ice-9/boot-9.scm:
   224:17 17 (map1 (#<procedure 1ac7640 at ice-9/psyntax.scm:1116:3…>))
In ice-9/psyntax.scm:
  1374:12 16 (_)
  1754:11 15 (lp (#(syntax-object (if (defined? (quote #)) #) # …) …) …)
  1644:45 14 (parse _ _ _ _ _ _ _)
In ice-9/boot-9.scm:
   224:17 13 (map1 (((("placeholder" placeholder) ("…" . #) …) . #) …))
In ice-9/psyntax.scm:
  1374:12 12 (_ _ _)
  1449:23 11 (_ _ _)
In ice-9/boot-9.scm:
   224:29 10 (map1 ((quote system-error) (lambda () (setlocale …)) #))
   224:29  9 (map1 ((lambda () (setlocale LC_ALL "")) (lambda # #)))
   224:17  8 (map1 ((lambda args (format (current-error-port) # #))))
In ice-9/psyntax.scm:
  1754:11  7 (lp ((format (current-error-port) "warning: failed…" …)) …)
  1577:33  6 (parse (((("placeholder" placeholder) ("…" . #) …) . #)) …)
  1298:27  5 (syntax-type (format (current-error-port) "warning:…" …) …)
  1282:39  4 (syntax-type format (("placeholder" placeholder) # # …) …)
   302:24  3 (resolve-identifier _ _ (("placeholder" placeholder) …) …)
In unknown file:
           2 (module-variable #<directory (guild) 1b76750> format)
In oop/goops.scm:
   1437:4  1 (cache-miss #<directory (guild) 1b76750> format #<inte…> …)
In unknown file:
           0 (scm-error goops-error #f "No applicable method for ~S…" …)

ERROR: In procedure scm-error:
ERROR: No applicable method for #<<generic> merge-generics (3)> in call
(merge-generics #<directory (guild) 1b76750> format #<interface (guile) 1b4eea0>
#<procedure 1c81cc0 at ice-9/format.scm:1609:9 (destination format-string . args) |
(deprecated-format-string-only)> #<autoload (ice-9 format) 1c60630> #<procedure
1c81cc0 at ice-9/format.scm:1609:9 (destination format-string . args) |
(deprecated-format-string-only)> #f #f) david <at> capac:~/gnu/grip/git/grip 9 $ 


BUT THIS Works:fine, in case it gives you come idea [it raises a warning though, is
this warning expected?]

david <at> capac:~/alto/projects/guile-tests/goops 3 $ guile
GNU Guile 2.1.3.52-8a087
Copyright (C) 1995-2016 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guile-user)> ,use (oop goops)
scheme@(guile-user)> (default-duplicate-binding-handler
    '(merge-generics replace warn-override-core warn last))

;;; warning: unknown warning type `macro-use-before-definition'
$1 = (#<<generic> merge-generics (3)> #<procedure replace (module name int1 val1
int2 val2 var val)> #<procedure warn-override-core (module name int1 val1 int2 val2
var val)> #<procedure warn (module name int1 val1 int2 val2 var val)> #<procedure
last (module name int1 val1 int2 val2 var val)>)

scheme@(guile-user)> ,use (system base compile)
scheme@(guile-user)> (compile-file "/home/david/gnu/grip/git/grip/reexport.scm")
;;; warning: unknown warning type `macro-use-before-definition'
$2 =
"/home/david/.cache/guile/ccache/2.2-LE-8-3.9/usr/alto/projects/gnu/grip/git/grip/reexport.scm.go"
scheme@(guile-user)> 


Sorry for the long email!
I hope you can help!

Cheers,
David

[Message part 2 (application/pgp-signature, inline)]

Information forwarded to bug-guile <at> gnu.org:
bug#20093; Package guile. (Sun, 03 Jul 2016 22:11:02 GMT) Full text and rfc822 format available.

Message #19 received at 20093 <at> debbugs.gnu.org (full text, mbox):

From: David Pirotte <david <at> altosw.be>
To: Andy Wingo <wingo <at> pobox.com>
Cc: 20093 <at> debbugs.gnu.org
Subject: Re: bug#20093: master: setting merge-generics
 duplicate-binding-handler @ expand time raises an error
Date: Sun, 3 Jul 2016 19:10:07 -0300
[Message part 1 (text/plain, inline)]
Hello Andy,

Further to the previous answer [of July the 2th 2016]

> ...
> But, you say, I only specified the duplicates handler after loading
> goops!  Well indeed, but if a module didn't specify #:duplicates, its
> duplicates handling was implicitly dynamically scoped to whatever the
> current default-duplicates-handlers were.  That seems bogus to me: the
> module declares its imports and exports and a lack of a declaration of
> #:duplicates indicates that the module is implicitly specifying the
> duplicate handlers that are described in the manual.

I disagree with the way you [now' re-] interpret things: if a module has no
#:duplicates declaration, it is implicitly specifying the duplicate handlers 
returned by (default-duplicate-binding-handler), _not_ the one from the
manual.

IMO, this was an API, and for me, a hard coded list instead of querying an API does
not offer any advantage, at the contrary, a step backward in 'power'.

> In master I have changed the `default-duplicate-binding-handler' to
> simply access the handlers for the current module, as that seems to be
> the correct thing.  Let me know how it goes!  Closing as done but let's
> follow up :)

This breaks all my code, with no other option but maintaining my own
boot-9 version: I really wish I can avoid that, could you reconsider? [no, I don't
want to have to use #:duplicates, since I _always_ [like always always always] want
my modules to grab my global setting and default].

As you understood by now, I need 2 things wrt duplicate handlers:

	1.	I must be able to patch guild, so it ,use (oop goops) and set
		these before I compile my modules [with or without --no-auto-compile
		does not matter]. All my scripts do so as well of course [1]

		#!/bin/sh
		# -*- scheme -*-
		exec ${GUILE:-/opt2/bin/guile} --no-auto-compile -e '(@@ (guild) main)' -s "$0" "$@"
		!#

		(eval-when (expand load eval)
		  (use-modules (oop goops))
		  (default-duplicate-binding-handler
		    '(merge-generics replace warn-override-core warn last)))

		...

		This does not work anymore, I hope it can be fixed

	2.	obviously, the above only make sense if modules grab
		(default-duplicate-binding-handler) when no #:duplicates declaration

		I can maintain my own boot-9 but wish to avoid this solution.

Cheers,
David

[1] http://git.savannah.gnu.org/cgit/grip.git/tree/grip/clutter/examples/bouncer.in
[Message part 2 (application/pgp-signature, inline)]

Information forwarded to bug-guile <at> gnu.org:
bug#20093; Package guile. (Thu, 07 Jul 2016 09:56:02 GMT) Full text and rfc822 format available.

Message #22 received at 20093 <at> debbugs.gnu.org (full text, mbox):

From: Andy Wingo <wingo <at> pobox.com>
To: David Pirotte <david <at> altosw.be>
Cc: 20093 <at> debbugs.gnu.org
Subject: Re: bug#20093: master: setting merge-generics
 duplicate-binding-handler @ expand time raises an error
Date: Thu, 07 Jul 2016 11:54:51 +0200
On Mon 04 Jul 2016 00:10, David Pirotte <david <at> altosw.be> writes:

>> But, you say, I only specified the duplicates handler after loading
>> goops!  Well indeed, but if a module didn't specify #:duplicates, its
>> duplicates handling was implicitly dynamically scoped to whatever the
>> current default-duplicates-handlers were.  That seems bogus to me: the
>> module declares its imports and exports and a lack of a declaration of
>> #:duplicates indicates that the module is implicitly specifying the
>> duplicate handlers that are described in the manual.
>
> I disagree with the way you [now' re-] interpret things: if a module has no
> #:duplicates declaration, it is implicitly specifying the duplicate handlers 
> returned by (default-duplicate-binding-handler), _not_ the one from the
> manual.

To clarify.  I believe that the default should be what is in the manual,
and have fixed Guile 2.2 in that regard.  You think it should be the
value of the dynamic parameter.  There are two points at which the
parameter could be captured: when the module is defined, or lazily, when
the first duplicate binding pair is detected.  The latter leads to bugs
of many kinds, like this bug.  So, I assume you are proposing to capture
the value of the dynamic parameter when the module is defined.  This has
two bugs however.

 * Modules are defined two times in general: once when compiling and
   once when loading.  It is too difficult to get the parameter to work
   when compiling; you have to do invoke
   (default-duplicate-binding-handler) at the top of each file you
   compile, at which point you might as well just specify #:duplicates.

 * Global dynamic parameters that affect the substance of a module and
   the shape of its exports are not modular and cannot be set in a
   modular way.  If your module depends on a particular duplicates
   handler, you need to specify that explicitly -- otherwise a user of
   your module might want something different in general, and then your
   code would break.

>> In master I have changed the `default-duplicate-binding-handler' to
>> simply access the handlers for the current module, as that seems to be
>> the correct thing.  Let me know how it goes!  Closing as done but let's
>> follow up :)
>
> This breaks all my code, with no other option but maintaining my own
> boot-9 version: I really wish I can avoid that, could you reconsider? [no, I don't
> want to have to use #:duplicates, since I _always_ [like always always always] want
> my modules to grab my global setting and default].

I feel your pain but I think that the proper solution is to just go
through your modules and add the #:duplicates argument.  It is forward
and backward compatible.

I also feel the need to say that while you are welcome to fork Guile in
any way that you like, I will not look at any bugs from a forked Guile.

Regards,

Andy




Information forwarded to bug-guile <at> gnu.org:
bug#20093; Package guile. (Thu, 07 Jul 2016 10:23:02 GMT) Full text and rfc822 format available.

Message #25 received at 20093 <at> debbugs.gnu.org (full text, mbox):

From: Andy Wingo <wingo <at> pobox.com>
To: David Pirotte <david <at> altosw.be>
Cc: 20093 <at> debbugs.gnu.org
Subject: Re: bug#20093: Fw: bug#20093: master: setting merge-generics
 duplicate-binding-handler @ expand time raises an error
Date: Thu, 07 Jul 2016 12:22:02 +0200
On Sun 03 Jul 2016 22:55, David Pirotte <david <at> altosw.be> writes:

> This is a big problem for me, so I partially locally reverted that part of
> the patch, plus, I patch guild so it does this before anything else:
>
> 	(eval-when (expand load eval)
> 	  (use-modules (oop goops))
> 	  (default-duplicate-binding-handler
> 	    '(merge-generics replace warn-override-core warn last)))

Hi,

It takes work for me to understand and fix reports and I regret to say
that patching "guild" is too much for me -- I don't have the time to
work on bugs in patched Guile versions where the patches are significant
(like this patch) and yet not headed towards mainline (also like this
patch).

Regards,

Andy




Information forwarded to bug-guile <at> gnu.org:
bug#20093; Package guile. (Mon, 25 Jul 2016 02:40:02 GMT) Full text and rfc822 format available.

Message #28 received at 20093 <at> debbugs.gnu.org (full text, mbox):

From: David Pirotte <david <at> altosw.be>
To: Andy Wingo <wingo <at> pobox.com>
Cc: 20093 <at> debbugs.gnu.org
Subject: Re: bug#20093: Fw: bug#20093: master: setting merge-generics
 duplicate-binding-handler @ expand time raises an error
Date: Sun, 24 Jul 2016 23:38:48 -0300
[Message part 1 (text/plain, inline)]
Hi Andy,

> > This is a big problem for me, so I partially locally reverted that part of
> > the patch, plus, I patch guild so it does this before anything else:

> > 	(eval-when (expand load eval)
> > 	  (use-modules (oop goops))
> > 	  (default-duplicate-binding-handler
> > 	    '(merge-generics replace warn-override-core warn last)))  

> It takes work for me to understand and fix reports and I regret to say
> that patching "guild" is too much for me -- I don't have the time to
> work on bugs in patched Guile versions where the patches are significant
> (like this patch) and yet not headed towards mainline (also like this
> patch).

Let's not get lost in 2 diff things here:

1- 

As a consequence of you looking at this bug report, you decided to change the
module system:

> In master I have changed the `default-duplicate-binding-handler' to
> simply access the handlers for the current module, as that seems to be
> the correct thing.  Let me know how it goes!  Closing as done but let's
> follow up :)  

I did think very carefully to this and our conversation, and I still think it as a
big mistake: if a module does not declare #:duplicates, the 'old' way is the right
way, calling (default-duplicate-binding-handler).

Yes, it would then be a user error not to properly globally set this at 'all
incantations', compile, load ... if they rely on a diff set then the defaul:

	the fact that users may miss use it does not justify it's been taken away:
	they are quite a lot of ways a user can write bugs, as you know, so let's
	get rid of set! then :)

IMO, this is an API, the right one, so it should not be changed.

Note that users of 'these modules' (the ones where you'd locally declare
#:duplicates) still have to set this in their repl and in their scripts, not doing
so would also be an user error and this 'new' model does not prevent these errors.

I have successfully used it for years now: it saves me to have to do it at module
level, and since I correctly set it globally: forcing me (and other users of this
API) sounds a bit of a brute forcing a certain programing style: since I know what
I'm doing, I don't see local declarations being 'better', but just another way to do
it. As a mater of fact, I see the global setting better and safer, because I'll never
forget...

Please think about this, thanks!

2-

Now, a separate thing is I can't set this in guild anymore. Ok, I read you, but guild
is a script, and IMO, there is no reason I can do it in a script of mine and not in
guild, this works fine:

;; compile-me script starts here
#! /bin/sh
# -*- mode: scheme; coding: utf-8 -*-
exec guile --no-auto-compile -e main -s $0 "$@"
!#

(eval-when (expand load eval)
  (use-modules (oop goops))
  (default-duplicate-binding-handler
    '(merge-generics replace warn-override-core warn last)))

(use-modules (system base compile)
	     (ice-9 match))
 
(define (main args)
	
  (pk (default-duplicate-binding-handler))
  (add-to-load-path (getcwd))
  (match args
    ((cmd file)
     (compile-file file)
     (display (string-append "I compiled you: "
			     file
			     "\n")))))
;; compile-me script ends here

	[ drop this somewhere, chmod a+x 

;; foo.scm starts here
(define-module (a)
  #:use-module (oop goops)
  #:export (<a>
	    !width))

(define-class <a> ()
  (width #:accessor !width
	 #:init-keyword #:width
	 #:init-value 0))
;; foo.scm ends here

	[ drop this aside compile-me

	./compile-me foo.scm
	2.1.3.59-516f7
	(merge-generics replace warn-override-core warn last)
	I compiled you: foo.scm

A modified version of the guild script to (eval-when ...), then 'guild compile
foo.scm fails as reported in earlier. Note that it does not matter whether the
module uses goops, import more then one and effectively merge generics, it simply
fails, as reported in the first email of this thread.

So if you keep this API we are talking about here, and I really think we should, I
can write and use my own script to compile my modules. I'd be curious to understand
why guild, modified as described above, did work in 2.0.11, 2.0.12, 2.1.2, but fails
with 2.1.3, but I also understand if you are not interested.

Cheers,
David
[Message part 2 (application/pgp-signature, inline)]

Information forwarded to bug-guile <at> gnu.org:
bug#20093; Package guile. (Mon, 25 Jul 2016 02:46:02 GMT) Full text and rfc822 format available.

Message #31 received at 20093 <at> debbugs.gnu.org (full text, mbox):

From: David Pirotte <david <at> altosw.be>
To: Andy Wingo <wingo <at> pobox.com>
Cc: 20093 <at> debbugs.gnu.org
Subject: Re: bug#20093: Fw: bug#20093: master: setting merge-generics
 duplicate-binding-handler @ expand time raises an error
Date: Sun, 24 Jul 2016 23:44:56 -0300
[Message part 1 (text/plain, inline)]
Hi again :)

> ...
> this works fine:

I realized just after I sent that the compile-me script was not the latest
version: no big deal, just this displays exactly what I pasted in the previous mail
Here it is:

;; compile-me script starts here
#! /bin/sh
# -*- mode: scheme; coding: utf-8 -*-
exec guile --no-auto-compile -e main -s $0 "$@"
!#


(eval-when (expand load eval)
  (use-modules (oop goops))
  (default-duplicate-binding-handler
    '(merge-generics replace warn-override-core warn last)))


(use-modules (system base compile)
	     (ice-9 match))

 
(define (main args)
  (display (version))
  (newline)
  (display (default-duplicate-binding-handler))
  (newline)
  (add-to-load-path (getcwd))
  (match args
    ((cmd file)
     (compile-file file)
     (display (string-append "I compiled you: "
			     file
			     "\n")))))
;; compile-me script ends here


Cheers,
David
[Message part 2 (application/pgp-signature, inline)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 22 Aug 2016 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 8 years and 298 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.