diff --git a/LOG b/LOG index 6b73a069ec..b783beadb2 100644 --- a/LOG +++ b/LOG @@ -1001,3 +1001,5 @@ compile.ss - clarify "unknown module" error message in determine-module-imports syntax.ss +- restore the import code on reset to provide consistent error message + syntax.ss, 8.ms \ No newline at end of file diff --git a/mats/8.ms b/mats/8.ms index 409086babc..6fa4d6d73f 100644 --- a/mats/8.ms +++ b/mats/8.ms @@ -8977,7 +8977,47 @@ (eval '(lookup f g) (environment '(testfile-lr-l3) '(lookup))))]) (eval '(lookup f g) (environment '(testfile-lr-l3) '(lookup)))))) "Exception in h: user requested failure with (make-it-fail) parameter\nException in h: user requested failure with (make-it-fail) parameter\n") -) + + ;; re-arm import code if it complains about a library that is not visible + (begin + (with-output-to-file "testfile-lr-l4.ss" + (lambda () + (pretty-print + '(library (testfile-lr-l4) + (export x) + (import (chezscheme)) + (define x 123)))) + 'replace) + (with-output-to-file "testfile-lr-p4.ss" + (lambda () + (for-each pretty-print + '((import (testfile-lr-l4) (scheme)) + (define (run args) + (guard (c [#t (display-condition c) (newline)]) + (pretty-print (top-level-value (car args) (environment (cdr args)))))) + (when (> x 0) ;; reference export + (let ([args (map string->symbol (command-line-arguments))]) + (if (= (length args) 2) + (begin + (run args) + (run args)) + (error #f "expected 2 args"))))))) + 'replace) + (separate-eval + '(parameterize ([compile-imported-libraries #t] [generate-wpo-files #t]) + (compile-program "testfile-lr-p4.ss") + (compile-whole-program "testfile-lr-p4.wpo" "testfile-lr-p4-visible" #t) + (compile-whole-program "testfile-lr-p4.wpo" "testfile-lr-p4-not-visible" #f))) + (equal? + (separate-eval + '(parameterize ([command-line-arguments '("x" "testfile-lr-l4")]) + (load-program "testfile-lr-p4-visible") + (load-program "testfile-lr-p4-not-visible"))) + (string-append + "123\n" + "123\n" + "Exception in visit: library (testfile-lr-l4) is not visible\n" + "Exception in visit: library (testfile-lr-l4) is not visible\n")))) (mat cross-library-optimization (begin diff --git a/s/syntax.ss b/s/syntax.ss index a20e5c89b6..239bb23d67 100644 --- a/s/syntax.ss +++ b/s/syntax.ss @@ -5147,10 +5147,11 @@ (when (eq? p 'loading) ($oops #f "attempt to import library ~s while it is still being loaded" (libdesc-path desc))) (libdesc-import-code-set! desc #f) - (for-each (lambda (req) (import-library (libreq-uid req))) (libdesc-import-req* desc)) - ($install-library-clo-info (libdesc-clo* desc)) - (libdesc-clo*-set! desc '()) - (p))]))] + (on-reset (libdesc-import-code-set! desc p) + (for-each (lambda (req) (import-library (libreq-uid req))) (libdesc-import-req* desc)) + ($install-library-clo-info (libdesc-clo* desc)) + (libdesc-clo*-set! desc '()) + (p)))]))] [else ($oops #f "library ~:s is not defined" uid)]))) ; invoking or visiting a possibly unloaded library occurs in two separate steps: