Hi all, Here's a reasonably simple patch for fixing #1188: if you request an import library to be emitted with "-j foo" and there's no such module defined, currently the compiler will silently continue. It's nicer to give an error because possibly the user misspelled or made some other mistake.
I'm not 100% happy with the way this patch mutates the import libraries list, but it's the simplest way I could think of. Another approach could be to maintain a second list with the libraries that were emitted and check the original list against that, but that's a bit more complicated and adds yet another global variable. Cheers, Peter
From 22d7344307fbc24676e7f37a539b30f6dc61f070 Mon Sep 17 00:00:00 2001 From: Peter Bex <pe...@more-magic.net> Date: Thu, 19 Nov 2015 15:58:37 +0100 Subject: [PATCH] Error out when emitting import libraries for nonexistant modules. This fixes #1188 --- NEWS | 2 ++ batch-driver.scm | 7 +++++++ core.scm | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/NEWS b/NEWS index eba4c91..e4c6f8a 100644 --- a/NEWS +++ b/NEWS @@ -48,6 +48,8 @@ work, removing the requirement for the inferred types to match declared types exactly. Specializations are matched from first to last to resolve ambiguities (#1214). + - When requesting to emit import libraries that don't exist, the + compiler now gives an error instead of quietly continuing (#1188). 4.10.1 diff --git a/batch-driver.scm b/batch-driver.scm index 514022d..7cf47cb 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 32005bf..c57d48e 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))))) -- 2.1.4
From 236e9cd882878462a944f2e92669ba87cd490690 Mon Sep 17 00:00:00 2001 From: Peter Bex <pe...@more-magic.net> Date: Thu, 19 Nov 2015 15:55:55 +0100 Subject: [PATCH] Error out when emitting import libraries for nonexistant modules. This fixes #1188 --- NEWS | 2 ++ batch-driver.scm | 7 +++++++ compiler.scm | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/NEWS b/NEWS index 4527b44..0c17541 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,8 @@ work, removing the requirement for the inferred types to match declared types exactly. Specializations are matched from first to last to resolve ambiguities (#1214). + - When requesting to emit import libraries that don't exist, the + compiler now gives an error instead of quietly continuing (#1188). 4.10.1 diff --git a/batch-driver.scm b/batch-driver.scm index a5fa323..044b671 100644 --- a/batch-driver.scm +++ b/batch-driver.scm @@ -470,6 +470,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/compiler.scm b/compiler.scm index 55dbda6..8e626fc 100644 --- a/compiler.scm +++ b/compiler.scm @@ -874,6 +874,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))))) -- 2.1.4
signature.asc
Description: Digital signature
_______________________________________________ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers