1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

fix define-module ordering

* module/ice-9/boot-9.scm (define-module): Fix to load the #:use-module
  clauses in the order in which they appear in the define-module form.
  Thanks to Jan Nieuwenhuizen for the report.

* test-suite/standalone/test-import-order: Add new test that
  define-module and use-modules resolve the interface in the right
  order.

* test-suite/standalone/Makefile.am:
* test-suite/standalone/test-import-order-a.scm:
* test-suite/standalone/test-import-order-b.scm:
* test-suite/standalone/test-import-order-c.scm:
* test-suite/standalone/test-import-order-d.scm: Aux files.
This commit is contained in:
Andy Wingo 2011-05-21 18:29:03 +02:00
parent 0dd8493cb3
commit ad4bd7c2c0
7 changed files with 55 additions and 3 deletions

View file

@ -3070,15 +3070,15 @@ module '(ice-9 q) '(make-q q-length))}."
#`(#:filename 'f . #,(parse #'args imp exp rex rep aut))) #`(#:filename 'f . #,(parse #'args imp exp rex rep aut)))
((#:use-module (name name* ...) . args) ((#:use-module (name name* ...) . args)
(and (and-map symbol? (syntax->datum #'(name name* ...)))) (and (and-map symbol? (syntax->datum #'(name name* ...))))
(parse #'args (cons #'((name name* ...)) imp) exp rex rep aut)) (parse #'args #`(#,@imp ((name name* ...))) exp rex rep aut))
((#:use-syntax (name name* ...) . args) ((#:use-syntax (name name* ...) . args)
(and (and-map symbol? (syntax->datum #'(name name* ...)))) (and (and-map symbol? (syntax->datum #'(name name* ...))))
#`(#:transformer '(name name* ...) #`(#:transformer '(name name* ...)
. #,(parse #'args (cons #'((name name* ...)) imp) exp rex rep aut))) . #,(parse #'args #`(#,@imp ((name name* ...))) exp rex rep aut)))
((#:use-module ((name name* ...) arg ...) . args) ((#:use-module ((name name* ...) arg ...) . args)
(and (and-map symbol? (syntax->datum #'(name name* ...)))) (and (and-map symbol? (syntax->datum #'(name name* ...))))
(parse #'args (parse #'args
(cons #`((name name* ...) #,@(parse-iface #'(arg ...))) imp) #`(#,@imp ((name name* ...) #,@(parse-iface #'(arg ...))))
exp rex rep aut)) exp rex rep aut))
((#:export (ex ...) . args) ((#:export (ex ...) . args)
(parse #'args imp #`(#,@exp ex ...) rex rep aut)) (parse #'args imp #`(#,@exp ex ...) rex rep aut))

View file

@ -75,6 +75,11 @@ TESTS += test-require-extension
check_SCRIPTS += test-guile-snarf check_SCRIPTS += test-guile-snarf
TESTS += test-guile-snarf TESTS += test-guile-snarf
check_SCRIPTS += test-import-order
TESTS += test-import-order
EXTRA_DIST += test-import-order-a.scm test-import-order-b.scm \
test-import-order-c.scm test-import-order-d.scm
# test-num2integral # test-num2integral
test_num2integral_SOURCES = test-num2integral.c test_num2integral_SOURCES = test-num2integral.c
test_num2integral_CFLAGS = ${test_cflags} test_num2integral_CFLAGS = ${test_cflags}

View file

@ -0,0 +1,31 @@
#!/bin/sh
exec guile -q -L "$builddir" -s "$0" "$@"
!#
(define-module (base)
#:export (push! order))
(define order '())
(define (push!)
(set! order `(,@order ,(module-name (current-module)))))
(define-module (test-1)
#:use-module (base)
#:use-module (test-import-order-a)
#:use-module (test-import-order-b))
(use-modules (test-import-order-c) (test-import-order-d))
(if (not (equal? order
'((test-import-order-a)
(test-import-order-b)
(test-import-order-c)
(test-import-order-d))))
(begin
(format (current-error-port) "Unexpected import order: ~a" order)
(exit 1))
(exit 0))
;; Local Variables:
;; mode: scheme
;; End:

View file

@ -0,0 +1,4 @@
(define-module (test-import-order-a)
#:use-module (base))
(push!)

View file

@ -0,0 +1,4 @@
(define-module (test-import-order-b)
#:use-module (base))
(push!)

View file

@ -0,0 +1,4 @@
(define-module (test-import-order-c)
#:use-module (base))
(push!)

View file

@ -0,0 +1,4 @@
(define-module (test-import-order-d)
#:use-module (base))
(push!)