Questionable behavior of WITH-COMPILATION-UNIT suppressing "undefined variable" warnings

Bug #1078460 reported by Douglas Katzman
6
This bug affects 1 person
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-COMPILATION-UNIT is concerned.

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-COMPILATION-UNIT even if a later DEFVAR defines the var.
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-get-a-warn.lisp":
(defun use-missingvar ()
  (+ somevar 9))
;; end of file

"minimal-def-it.lisp":
(defvar somevar)
;; end of file

* (with-compilation-unit ()
  (format t "RESULT: ~S~%" ; compile reports no warning
   (multiple-value-call 'list (compile-file "minimal-get-a-warn")))
  (load "minimal-get-a-warn" :print t)
  (format t "RESULT: ~S~%" ; compile reports no warning
   (multiple-value-call 'list (compile-file "minimal-def-it")))
  ;; warning is signaled on exiting the compilation unit
  )

; compiling file "/ita/src/trunk/QPX/lw/minimal-get-a-warn.lisp" (written 13 NOV 2012 03:51:25 PM):
; compiling (DEFUN USE-MISSINGVAR ...)

; /ita/src/trunk/QPX/lw/minimal-get-a-warn.fasl written
; compilation finished in 0:00:00.003
RESULT: (#P"/ita/src/trunk/QPX/lw/minimal-get-a-warn.fasl" NIL NIL)
; compiling file "/ita/src/trunk/QPX/lw/minimal-def-it.lisp" (written 13 NOV 2012 03:51:48 PM):
; compiling (DEFVAR SOMEVAR)

; /ita/src/trunk/QPX/lw/minimal-def-it.fasl written
; compilation finished in 0:00:00.001
RESULT: (#P"/ita/src/trunk/QPX/lw/minimal-def-it.fasl" NIL NIL)

; file: /ita/src/trunk/QPX/lw/minimal-get-a-warn.lisp
; 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.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.