From: Nikodemus Siivola Date: Sat, 19 Mar 2011 14:31:29 +0000 (+0000) Subject: 1.0.46.37: SIMPLE-CONDITION slots are initialized with NIL if not supplied X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=0a8778552a8499dd4614c9aada7dfca3dfcc6997;p=sbcl.git 1.0.46.37: SIMPLE-CONDITION slots are initialized with NIL if not supplied So says CLHS. When there is no format control and *PRINT-ESCAPE* is false, signal an error. --- diff --git a/NEWS b/NEWS index 14d3cb3..7457a82 100644 --- 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. diff --git a/src/code/condition.lisp b/src/code/condition.lisp index a2d690a..fc216f0 100644 --- a/src/code/condition.lisp +++ b/src/code/condition.lisp @@ -171,9 +171,11 @@ ;;; 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 @@ -589,18 +591,21 @@ (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)) diff --git a/src/compiler/fndb.lisp b/src/compiler/fndb.lisp index 73e3db1..8d8f52e 100644 --- a/src/compiler/fndb.lisp +++ b/src/compiler/fndb.lisp @@ -1277,7 +1277,7 @@ (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) diff --git a/tests/condition.pure.lisp b/tests/condition.pure.lisp index 835818e..dc6877d 100644 --- a/tests/condition.pure.lisp +++ b/tests/condition.pure.lisp @@ -163,3 +163,19 @@ (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))))))) diff --git a/version.lisp-expr b/version.lisp-expr index f9b05c7..d85c22e 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -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"