GNU bug report logs -
#12202
psyntax defeats autoload
Previous Next
Reported by: ludo <at> gnu.org (Ludovic Courtès)
Date: Tue, 14 Aug 2012 16:25:02 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 12202 in the body.
You can then email your comments to 12202 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-guile <at> gnu.org
:
bug#12202
; Package
guile
.
(Tue, 14 Aug 2012 16:25:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
ludo <at> gnu.org (Ludovic Courtès)
:
New bug report received and forwarded. Copy sent to
bug-guile <at> gnu.org
.
(Tue, 14 Aug 2012 16:25:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hello!
Consider this module:
--8<---------------cut here---------------start------------->8---
(define-module (foo) #:autoload (does-not-exist) (baz))
(define (chbouib) (baz))
(pk 'hello)
--8<---------------cut here---------------end--------------->8---
Trying to evaluate it fails this way:
--8<---------------cut here---------------start------------->8---
$ guile --no-auto-compile t.scm
Backtrace:
In ice-9/boot-9.scm:
[...]
292: 3 [get-global-definition-hook baz (hygiene foo)]
In unknown file:
?: 2 [module-variable #<directory (foo) b3b510> baz]
In ice-9/boot-9.scm:
2732: 1 [b #<autoload (does-not-exist) b3b3f0> baz #f]
In unknown file:
?: 0 [scm-error misc-error #f ...]
ERROR: In procedure scm-error:
ERROR: missing interface for module (does-not-exist)
--8<---------------cut here---------------end--------------->8---
... which defeats the whole purpose of autoloads.
What about something along these lines (untested)?
[Message part 2 (text/x-patch, inline)]
diff --git a/module/ice-9/psyntax.scm b/module/ice-9/psyntax.scm
index 6c264a6..8a30f82 100644
--- a/module/ice-9/psyntax.scm
+++ b/module/ice-9/psyntax.scm
@@ -289,15 +289,20 @@
(lambda (symbol module)
(if (and (not module) (current-module))
(warn "module system is booted, we should have a module" symbol))
- (let ((v (module-variable (if module
+ (let ((m (if module
(resolve-module (cdr module))
- (current-module))
- symbol)))
+ (current-module))))
+ (case (module-kind m)
+ ((autoload)
+ ;; don't try to actually load the module
+ #t)
+ (else
+ (let ((v (module-variable m symbol)))
(and v (variable-bound? v)
(let ((val (variable-ref v)))
(and (macro? val) (macro-type val)
(cons (macro-type val)
- (macro-binding val)))))))))
+ (macro-binding val))))))))))))
(define (decorate-source e s)
[Message part 3 (text/plain, inline)]
Thanks,
Ludo’.
Information forwarded
to
bug-guile <at> gnu.org
:
bug#12202
; Package
guile
.
(Tue, 05 Mar 2013 18:55:04 GMT)
Full text and
rfc822 format available.
Message #8 received at 12202 <at> debbugs.gnu.org (full text, mbox):
On Tue 14 Aug 2012 18:14, ludo <at> gnu.org (Ludovic Courtès) writes:
> (define-module (foo) #:autoload (does-not-exist) (baz))
> (define (chbouib) (baz))
> (pk 'hello)
>
> Trying to evaluate it fails this way:
>
> $ guile --no-auto-compile t.scm
> Backtrace:
> In ice-9/boot-9.scm:
>
> [...]
>
> 292: 3 [get-global-definition-hook baz (hygiene foo)]
> In unknown file:
> ?: 2 [module-variable #<directory (foo) b3b510> baz]
> In ice-9/boot-9.scm:
> 2732: 1 [b #<autoload (does-not-exist) b3b3f0> baz #f]
> In unknown file:
> ?: 0 [scm-error misc-error #f ...]
>
> ERROR: In procedure scm-error:
> ERROR: missing interface for module (does-not-exist)
>
> ... which defeats the whole purpose of autoloads.
>
> What about something along these lines (untested)?
This is a great idea. We should assume that autoloads are not macros.
Not sure we can change it in 2.0 though, because there could be uses of
autoloaded macros.
However your patch won't work:
> diff --git a/module/ice-9/psyntax.scm b/module/ice-9/psyntax.scm
> index 6c264a6..8a30f82 100644
> --- a/module/ice-9/psyntax.scm
> +++ b/module/ice-9/psyntax.scm
> @@ -289,15 +289,20 @@
> (lambda (symbol module)
> (if (and (not module) (current-module))
> (warn "module system is booted, we should have a module" symbol))
> - (let ((v (module-variable (if module
> + (let ((m (if module
> (resolve-module (cdr module))
> - (current-module))
> - symbol)))
> + (current-module))))
> + (case (module-kind m)
> + ((autoload)
> + ;; don't try to actually load the module
> + #t)
> + (else
> + (let ((v (module-variable m symbol)))
> (and v (variable-bound? v)
> (let ((val (variable-ref v)))
> (and (macro? val) (macro-type val)
> (cons (macro-type val)
> - (macro-binding val)))))))))
> + (macro-binding val))))))))))))
>
because the module-kind of the module will never be `autoload' here. As
you can see in your backtrace, the module-kind is `directory' -- the
autoload only ends up getting loaded while grovelling (foo)'s import
array.
Andy
--
http://wingolog.org/
Reply sent
to
Andy Wingo <wingo <at> pobox.com>
:
You have taken responsibility.
(Wed, 13 Mar 2013 09:03:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
ludo <at> gnu.org (Ludovic Courtès)
:
bug acknowledged by developer.
(Wed, 13 Mar 2013 09:03:03 GMT)
Full text and
rfc822 format available.
Message #13 received at 12202-done <at> debbugs.gnu.org (full text, mbox):
On Tue 05 Mar 2013 17:45, Andy Wingo <wingo <at> pobox.com> writes:
>> ERROR: In procedure scm-error:
>> ERROR: missing interface for module (does-not-exist)
>>
>> ... which defeats the whole purpose of autoloads.
I pushed something that simply wraps the module binder in the autoload
with a false-if-exception (that also prints a warning).
Initially I wrapped the call to resolve-module / module-variable in
psyntax.scm's get-global-definition-hook with the false-if-exception,
but I ran into something interesting. memoize-expression, written in
memoize.c, has the job of turning tree-il into something the evaluator
can deal with. It has to specially recognize some toplevel
applications -- like @apply. It does this... by looking up the
variable! So that was another place autoloads could be defeated.
In the end I would have to wrap scm_module_variable
(scm_current_module(), sym) with a catch, and that's silly -- of course
resolving some other module can fail, but you don't expect
module-variable on a known module to throw an exception. So for that
reason it made sense to me to prevent the autoload module binder from
propagating an exception.
Andy
--
http://wingolog.org/
Information forwarded
to
bug-guile <at> gnu.org
:
bug#12202
; Package
guile
.
(Thu, 14 Mar 2013 13:23:01 GMT)
Full text and
rfc822 format available.
Message #16 received at 12202-done <at> debbugs.gnu.org (full text, mbox):
Andy Wingo <wingo <at> pobox.com> skribis:
> On Tue 05 Mar 2013 17:45, Andy Wingo <wingo <at> pobox.com> writes:
>
>>> ERROR: In procedure scm-error:
>>> ERROR: missing interface for module (does-not-exist)
>>>
>>> ... which defeats the whole purpose of autoloads.
>
> I pushed something that simply wraps the module binder in the autoload
> with a false-if-exception (that also prints a warning).
Great, thank you!
Ludo’.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 12 Apr 2013 11:24:06 GMT)
Full text and
rfc822 format available.
This bug report was last modified 11 years and 16 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.