bug-guile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#12202: psyntax defeats autoload


From: Ludovic Courtès
Subject: bug#12202: psyntax defeats autoload
Date: Tue, 14 Aug 2012 18:14:26 +0200
User-agent: Gnus/5.130005 (Ma Gnus v0.5) Emacs/24.1 (gnu/linux)

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)?

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)
Thanks,
Ludo’.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]