~ chicken-core (chicken-5) d63741b79bbeac34971e0ef0600e51e93453b11c


commit d63741b79bbeac34971e0ef0600e51e93453b11c
Author:     Peter Bex <peter@more-magic.net>
AuthorDate: Thu Nov 19 15:58:37 2015 +0100
Commit:     Evan Hanson <evhan@foldling.org>
CommitDate: Fri Jan 1 17:08:32 2016 +1300

    Error out when emitting import libraries for nonexistant modules
    
    This fixes #1188.
    
    Signed-off-by: Evan Hanson <evhan@foldling.org>

diff --git a/NEWS b/NEWS
index f5d0e256..c68f99a8 100644
--- a/NEWS
+++ b/NEWS
@@ -51,6 +51,8 @@
      declared types exactly.  Specializations are matched from first to
      last to resolve ambiguities (#1214).
   - Compiler rewrites for char{<,>,<=,>=,=}? are now safe (#1122).
+  - When requesting to emit import libraries that don't exist, the
+     compiler now gives an error instead of quietly continuing (#1188).
 
 - Core libraries
   - Irregex has been updated to 0.9.4, which fixes severe performance
diff --git a/batch-driver.scm b/batch-driver.scm
index 514022d6..7cf47cbb 100644
--- a/batch-driver.scm
+++ b/batch-driver.scm
@@ -587,6 +587,13 @@
 			     '() )
 			 '((##core#undefined))) ) )
 
+	     (unless (null? import-libraries)
+	       (quit "No module definition found for import libraries to emit: ~A"
+		     ;; ~S would be confusing: separate with a comma
+		     (string-intersperse
+		      (map (lambda (il) (->string (car il)))
+			   import-libraries) ", ")))
+
 	     (when (pair? compiler-syntax-statistics)
 	       (with-debugging-output
 		'S
diff --git a/core.scm b/core.scm
index fb70c6f2..f9707b36 100644
--- a/core.scm
+++ b/core.scm
@@ -967,6 +967,10 @@
 							    (lambda (il)
 							      (when enable-module-registration
 								(emit-import-lib name il))
+							      ;; Remove from list
+							      ;; to avoid error
+							      (set! import-libraries
+								(delete il import-libraries))
 							      (values
 							       (reverse xs)
 							       '((##core#undefined)))))
Trap