diff --git a/lib/chibi/repl.scm b/lib/chibi/repl.scm index 45c9084a..82877800 100644 --- a/lib/chibi/repl.scm +++ b/lib/chibi/repl.scm @@ -323,17 +323,49 @@ 0 (- (string-length mod-file) 4)) ".scm"))) - (display "Searched module path " out) - (display (current-module-path) out) - (display " for " out) - (write mod-file out) - (display ".\n" out) (cond - ((find-module-file scm-file) - => (lambda (file) - (display "But found non-module-definition file " out) - (write file out) - (display ".\nNote module files must end in \".sld\".\n" out))))) + ((find-module-file mod-file) + => (lambda (path) + (let ((defined-mod-name + (protect (exn (else #f)) + (let ((x (call-with-input-file path read))) + (and (pair? x) + (pair? (cdr x)) + (eq? 'define-library (car x)) + (cadr x)))))) + (cond + ((not defined-mod-name) + (display "File '" out) + (display path out) + (display "' does not appear to define module " out) + (display mod-name out) + (display ".\n" out)) + ((equal? defined-mod-name mod-name) + (display "File '" out) + (display path out) + (display "' failed to define module " out) + (display mod-name out) + (display ".\n" out)) + (else + (display "Expected file '" out) + (display path out) + (display "' to define module " out) + (display mod-name out) + (display " but found " out) + (display defined-mod-name out) + (display ".\n" out)))))) + (else + (display "Searched module path " out) + (display (current-module-path) out) + (display " for " out) + (write mod-file out) + (display ".\n" out) + (cond + ((find-module-file scm-file) + => (lambda (file) + (display "But found non-module-definition file " out) + (write file out) + (display ".\nNote module files must end in \".sld\".\n" out))))))) ))) (define undefined-value (if #f #f))