From: Chris Hanson Date: Sun, 20 Oct 2019 20:07:17 +0000 (-0700) Subject: Improve error reporting for library imports. X-Git-Tag: mit-scheme-pucked-10.1.20~11^2~32 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=234cbb6531fdb76d804728a0c5d64d6dd414d3a3;p=mit-scheme.git Improve error reporting for library imports. --- diff --git a/src/runtime/library-database.scm b/src/runtime/library-database.scm index 640d96df2..23919a9ab 100644 --- a/src/runtime/library-database.scm +++ b/src/runtime/library-database.scm @@ -36,7 +36,10 @@ USA. (hash-table-exists? table name)) (define (get name) - (hash-table-ref table name)) + (let ((library (hash-table-ref/default table name #f))) + (if (not library) + (error "No library of this name in database:" name this)) + library)) (define (put! library) (if (and (library 'has? 'db) @@ -115,7 +118,7 @@ USA. (if (not auto) (error "Unknown property:" key)) (if (not (auto-runnable? auto this)) - (error "Auto property not ready:" auto)) + (error "Auto property not ready:" key)) (let ((bindings (run-auto auto this))) (set-cdr! alist (append bindings (cdr alist))) (cdr (assq key bindings))))))) diff --git a/src/runtime/library-imports.scm b/src/runtime/library-imports.scm index dac164794..33da1e588 100644 --- a/src/runtime/library-imports.scm +++ b/src/runtime/library-imports.scm @@ -29,12 +29,15 @@ USA. (declare (usual-integrations)) -(define (parsed-import-expandable? import db) - (let ((name (parsed-import-library import))) - (and (registered-library? name db) - ((registered-library name db) 'has? 'exports)))) - (define (expand-parsed-imports imports db) + (let ((unusable + (remove (lambda (import) + (let ((name (parsed-import-library import))) + (and (registered-library? name db) + ((registered-library name db) 'has? 'exports)))) + imports))) + (if (pair? unusable) + (error "Unknown imports:" (map parsed-import-library unusable)))) (reduce-right append! '() (map (lambda (import) @@ -42,10 +45,7 @@ USA. imports))) (define-automatic-property 'imports '(parsed-imports db) - (lambda (imports db) - (every (lambda (import) - (parsed-import-expandable? import db)) - imports)) + #f expand-parsed-imports) ;;; Returns a list of library-import elements. diff --git a/src/runtime/library-loader.scm b/src/runtime/library-loader.scm index 6deda0267..7dd55fbef 100644 --- a/src/runtime/library-loader.scm +++ b/src/runtime/library-loader.scm @@ -130,12 +130,6 @@ USA. (define (environment . import-sets) (let ((parsed (map parse-import-set import-sets)) (db host-library-db)) - (let ((unusable - (remove (lambda (import) - (parsed-import-expandable? import db)) - parsed))) - (if (pair? unusable) - (error "Imports not usable:" unusable))) (let ((imports (expand-parsed-imports parsed db))) (let ((unavailable (remove (lambda (import) diff --git a/src/runtime/runtime.pkg b/src/runtime/runtime.pkg index 0056b3ee4..e20ba5383 100644 --- a/src/runtime/runtime.pkg +++ b/src/runtime/runtime.pkg @@ -6086,8 +6086,7 @@ USA. (files "library-imports") (parent (runtime library)) (export (runtime library) - expand-parsed-imports - parsed-import-expandable?)) + expand-parsed-imports)) (define-package (runtime library scode) (files "library-scode")