--- Begin Message ---
Subject: |
Autoloads behave differently in Guile ≥ 2.9.7 |
Date: |
Fri, 03 Jan 2020 16:56:57 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) |
Hello!
It seems that since 2.9.7, autoloads have to specify exactly all the
bindings of the autoloaded module that the user will ever reference.
Bindings that are omitted from the #:autoload clause remain unbound:
--8<---------------cut here---------------start------------->8---
ludo@ribbon /tmp [env]$ cat a.scm
(define-module (a)
#:export (foo bar))
(define foo 42)
(define bar 43)
ludo@ribbon /tmp [env]$ cat b.scm
(define-module (b)
#:autoload (a) (foo))
(pk '-> foo)
(pk '=> bar)
ludo@ribbon /tmp [env]$ guild compile -Wunbound-variable -L . b.scm
b.scm:5:0: warning: possibly unbound variable `bar'
wrote `/home/ludo/.cache/guile/ccache/3.0-LE-8-4.1/tmp/b.scm.go'
ludo@ribbon /tmp [env]$ guile -L . -l b.scm -q
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;; or pass the --no-auto-compile argument to disable.
;;; compiling ./a.scm
;;; compiled /home/ludo/.cache/guile/ccache/3.0-LE-8-4.1/tmp/a.scm.go
;;; (-> 42)
Backtrace:
In ice-9/boot-9.scm:
1722:10 6 (with-exception-handler _ _ #:unwind? _ # _)
In unknown file:
5 (apply-smob/0 #<thunk 7f976447aa40>)
In ice-9/boot-9.scm:
718:2 4 (call-with-prompt _ _ #<procedure default-prompt-handle…>)
In ice-9/eval.scm:
619:8 3 (_ #(#(#<directory (guile-user) 7f9764071f00>)))
In ice-9/boot-9.scm:
2792:4 2 (save-module-excursion _)
4336:12 1 (_)
In b.scm:
5:0 0 (_)
b.scm:5:0: Unbound variable: bar
ludo@ribbon /tmp [env]$ guile --version
guile (GNU Guile) 2.9.8
--8<---------------cut here---------------end--------------->8---
That’s different from previous Guile behavior:
--8<---------------cut here---------------start------------->8---
ludo@ribbon /tmp$ guild compile -Wunbound-variable -L . b.scm
wrote `/home/ludo/.cache/guile/ccache/2.2-LE-8-3.A/tmp/b.scm.go'
ludo@ribbon /tmp$ guile -L . -l b.scm -q
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;; or pass the --no-auto-compile argument to disable.
;;; compiling ./a.scm
;;; compiled /home/ludo/.cache/guile/ccache/2.2-LE-8-3.A/tmp/a.scm.go
;;; (-> 42)
;;; (=> 43)
GNU Guile 2.2.6
Copyright (C) 1995-2019 Free Software Foundation, Inc.
--8<---------------cut here---------------end--------------->8---
Reverting cb14fd214365e50b6b1655616ae74d0228933bbd solves the problem,
or simply applying this change:
diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm
index b602de228..adbf5ba5d 100644
--- a/module/ice-9/boot-9.scm
+++ b/module/ice-9/boot-9.scm
@@ -3420,7 +3420,7 @@ error if selected binding does not exist in the used
module."
(let ((b (lambda (a sym definep)
(false-if-exception
(and (memq sym bindings)
- (let ((i (resolve-interface name #:select bindings)))
+ (let ((i (module-public-interface (resolve-module name))))
(unless i
(error "missing interface for module" name))
(let ((uses (memq a (module-uses module))))
The new semantics make sense, but I would rather err on the side of
compatibility.
WDYT?
Thanks,
Ludo’.
--- End Message ---
--- Begin Message ---
Subject: |
Re: bug#38895: Autoloads behave differently in Guile ≥ 2.9.7 |
Date: |
Sun, 12 Jan 2020 21:23:55 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) |
On Fri 03 Jan 2020 16:56, Ludovic Courtès <address@hidden> writes:
> It seems that since 2.9.7, autoloads have to specify exactly all the
> bindings of the autoloaded module that the user will ever reference.
> Bindings that are omitted from the #:autoload clause remain unbound:
Indeed. This was an unintentional change, in the sense that I thought
that the previous behavior was to only import the referenced bindings.
As discussed on IRC we decided to leave it with the new behavior, add a
NEWS entry, and we can roll back if it's really a pain to people.
Thanks for finding the issue!
Andy
--- End Message ---