Questionable behavior of WITH-COMPILATION-UNIT suppressing "undefined variable" warnings
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
New
|
Undecided
|
Unassigned |
Bug Description
An "undefined variable" warning can never actually be favorably resolved in the way that an "undefined function" can be, as far as SUMMARIZE-
But because the warning is deferred, COMPILE-FILE can return WARNINGS-P = NIL when a warning happened, and when it is a forgone conclusion that the warning will be printed.
This makes it difficult for automated build systems, which would like to think that the overall result of "did warnings occur" is simply the "most pessimal" value from any COMPILE-FILE. Granted this is a problem in general where there is good reason for deferring the warning.
However some discussion with Martin Cracacuer and Fare is that deferring the "undefined variable" warning probably makes no sense in the first place. It will cause some output from SUMMARIZE-
ASDF in particular does not understand that even if every compile says "no warning", the overall result might be "yes warning".
I think the language in CLHS is pretty clear in not mandating deferral of all warnings: "If an implementation would normally defer certain kinds of warnings, such as warnings about undefined functions, to the end of a compilation unit..."
So it's totally legal to say that a an "undefined variable" warning would not normally be deferred.
Minimal example:
"minimal-
(defun use-missingvar ()
(+ somevar 9))
;; end of file
"minimal-
(defvar somevar)
;; end of file
* (with-compilati
(format t "RESULT: ~S~%" ; compile reports no warning
(multiple-
(load "minimal-
(format t "RESULT: ~S~%" ; compile reports no warning
(multiple-
;; warning is signaled on exiting the compilation unit
)
; compiling file "/ita/src/
; compiling (DEFUN USE-MISSINGVAR ...)
; /ita/src/
; compilation finished in 0:00:00.003
RESULT: (#P"/ita/
; compiling file "/ita/src/
; compiling (DEFVAR SOMEVAR)
; /ita/src/
; compilation finished in 0:00:00.001
RESULT: (#P"/ita/
; file: /ita/src/
; in: DEFUN USE-MISSINGVAR
; (+ SOMEVAR 9)
;
; caught WARNING:
; undefined variable: SOMEVAR
;
; compilation unit finished
; Undefined variable:
; SOMEVAR
; caught 1 WARNING condition
NIL
In the above example we'd like that the second return value of COMPILE-FILE from the first file be T.