From 0e8b426f52c6c684be38fc829e24f9380b906919 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 23 May 2021 18:21:24 -0700 Subject: compiler: bugfix: warnings deferred too far. Because with-compilation-unit is keyed of *load-recursive*, when compilation is happening in the context of a load (a top-level form in a loaded file calls compile-file or compile-update file) warnings are deferred until the end of the load. That might never occur if the load doesn't complete, because, say, the image quits for some reason. If the following is the content of a file which is loaded: (compile-file "foo") (exit 0) then warnings during the compilation are not issued when compile-file terminates, and will never be issued because of the termination due to the exit call. * share/txr/stdlib/compiler.tl (*in-compilation-unit*): New special variable. (with-compilation-unit): Use *in-compilation-unit* to determinw when a compilation unit has ended, and dump all the deferred warnings then. We will bind *load-recursive* because that is required for deferring warnings. --- share/txr/stdlib/compiler.tl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/share/txr/stdlib/compiler.tl b/share/txr/stdlib/compiler.tl index 0e0f3f4f..e56dea66 100644 --- a/share/txr/stdlib/compiler.tl +++ b/share/txr/stdlib/compiler.tl @@ -334,6 +334,8 @@ (defvarl assumed-fun) +(defvar *in-compilation-unit* nil) + (defvar *dedup*) (defvar *unchecked-calls*) @@ -2219,7 +2221,8 @@ (defmacro usr:with-compilation-unit (. body) (with-gensyms (rec) - ^(let* ((,rec sys:*load-recursive*) + ^(let* ((,rec *in-compilation-unit*) + (*in-compilation-unit* t) (sys:*load-recursive* t) (*dedup* (or *dedup* (hash)))) (unwind-protect -- cgit v1.2.3