Thanks megane!

On 2021-04-22 14:00, megane wrote:
> ITYM it'll never trigger an error, even if the the filname is symbol for
> example.

In the use case where FILENAME is a string you will hit this:

    $ csc -analyze-only - <<EOF
    (declare (emit-import-library (foo "nope.import.scm")))
    (module foo *)
    EOF
    
    Error: (string) bad argument type: "nope.import.scm"

That's how I originally ran into this.

But, now that you mention it, on closer inspection the validation for
this declaration doesn't even have the intended effect since invalid
specifications will cause #<undefined> to be added to the alist of
import libraries, leading to an error later in the compilation process:

    $ csc -analyze-only - <<EOF
    (declare (emit-import-library (foo nope.import.scm)))
    (module foo *)
    EOF
    
    Warning: invalid import-library specification: (foo nope.import.scm)
    
    Error: (assq) bad argument type: #<unspecified>

Attached is a fix for *this* issue, in which we "quit-compiling" rather
than warn when the declaration is invalid.

Sorry I didn't notice this in the first place!

Evan
>From 92fc80908427cf8c998d397eb7541db6190210dc Mon Sep 17 00:00:00 2001
From: Evan Hanson <[email protected]>
Date: Fri, 23 Apr 2021 12:06:54 +1200
Subject: [PATCH] Quit compiling when an invalid import-Library declaration is
 encountered

---
 core.scm | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/core.scm b/core.scm
index f624781d..a6f8d3cf 100644
--- a/core.scm
+++ b/core.scm
@@ -1719,8 +1719,7 @@
                              (symbol? (car il)) (string? (cadr il)))
                         (cons (car il) (cadr il)))
                        (else
-                        (warning
-                         "invalid import-library specification" il))))
+                        (quit-compiling "invalid `import-library' 
specification: ~S" il))))
                (strip-syntax (cdr spec))))))
        ((emit-types-file)
         (unless types-output-file
-- 
2.29.3

Reply via email to