1.0.46.37: SIMPLE-CONDITION slots are initialized with NIL if not supplied
authorNikodemus Siivola <nikodemus@random-state.net>
Sat, 19 Mar 2011 14:31:29 +0000 (14:31 +0000)
committerNikodemus Siivola <nikodemus@random-state.net>
Sat, 19 Mar 2011 14:31:29 +0000 (14:31 +0000)
  So says CLHS.

  When there is no format control and *PRINT-ESCAPE* is false,
  signal an error.

NEWS
src/code/condition.lisp
src/compiler/fndb.lisp
tests/condition.pure.lisp
version.lisp-expr

diff --git a/NEWS b/NEWS
index 14d3cb3..7457a82 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -40,6 +40,7 @@ changes relative to sbcl-1.0.46:
     variable reference to refer to a variable not in scope, causing an error
     during physical environment analysis when attempting to close over the
     variable. (lp#551227)
+  * bug fix: SIMPLE-CONDITION :FORMAT-CONTROL defaults to NIL.
 
 changes in sbcl-1.0.46 relative to sbcl-1.0.45:
   * enhancement: largefile support on Solaris.
index a2d690a..fc216f0 100644 (file)
 ;;; The current code doesn't seem to quite match that.
 (def!method print-object ((x condition) stream)
   (if *print-escape*
-      (if (and (typep x 'simple-condition) (slot-boundp x 'format-control))
+      (if (and (typep x 'simple-condition) (slot-value x 'format-control))
           (print-unreadable-object (x stream :type t :identity t)
-            (format stream "~S" (simple-condition-format-control x)))
+            (write (simple-condition-format-control x)
+                   :stream stream
+                   :lines 1))
           (print-unreadable-object (x stream :type t :identity t)))
       ;; KLUDGE: A comment from CMU CL here said
       ;;   7/13/98 BUG? CPL is not sorted and results here depend on order of
 (define-condition style-warning (warning) ())
 
 (defun simple-condition-printer (condition stream)
-  (apply #'format
-         stream
-         (simple-condition-format-control condition)
-         (simple-condition-format-arguments condition)))
+  (let ((control (simple-condition-format-control condition)))
+    (if control
+        (apply #'format stream
+               control
+               (simple-condition-format-arguments condition))
+        (error "No format-control for ~S" condition))))
 
 (define-condition simple-condition ()
   ((format-control :reader simple-condition-format-control
                    :initarg :format-control
+                   :initform nil
                    :type format-control)
    (format-arguments :reader simple-condition-format-arguments
                      :initarg :format-arguments
-                     :initform '()
+                     :initform nil
                      :type list))
   (:report simple-condition-printer))
 
index 73e3db1..8d8f52e 100644 (file)
 (defknown method-combination-error (format-control &rest t) *)
 (defknown signal (t &rest t) null)
 (defknown simple-condition-format-control (condition)
-  format-control)
+  (or null format-control))
 (defknown simple-condition-format-arguments (condition)
   list)
 (defknown warn (t &rest t) null)
index 835818e..dc6877d 100644 (file)
                   (assert (equal '(restart-case (foo :report "quux" (quux)))
                                  (simple-condition-format-arguments e)))
                   :ok)))))
+
+(with-test (:name :simple-condition-without-args)
+  (let ((sc (make-condition 'simple-condition)))
+    (assert (not (simple-condition-format-control sc)))
+    (assert (not (simple-condition-format-arguments sc)))
+    (assert (stringp (prin1-to-string sc)))
+    (assert
+     (eq :ok
+         (handler-case
+             (princ-to-string sc)
+           (simple-error (c)
+             (when (and (equal "No format-control for ~S"
+                               (simple-condition-format-control c))
+                        (eq sc (car
+                                (simple-condition-format-arguments c))))
+               :ok)))))))
index f9b05c7..d85c22e 100644 (file)
@@ -20,4 +20,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"1.0.46.36"
+"1.0.46.37"