;;; The current code doesn't seem to quite match that.
(def!method print-object ((x condition) stream)
(if *print-escape*
- (print-unreadable-object (x stream :type t :identity t))
+ (if (and (typep x 'simple-condition) (slot-boundp x 'format-control))
+ (print-unreadable-object (x stream :type t :identity t)
+ (format stream "~S" (simple-condition-format-control x)))
+ (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
;; superclasses in define-condition call!
',(all-writers)
(sb!c:source-location)))))))
\f
-;;;; DESCRIBE on CONDITIONs
-
-;;; a function to be used as the guts of DESCRIBE-OBJECT (CONDITION T)
-;;; eventually (once we get CLOS up and running so that we can define
-;;; methods)
-(defun describe-condition (condition stream)
- (format stream
- "~&~@<~S ~_is a ~S. ~_Its slot values are ~_~S.~:>~%"
- condition
- (type-of condition)
- (concatenate 'list
- (condition-actual-initargs condition)
- (condition-assigned-slots condition))))
-\f
;;;; various CONDITIONs specified by ANSI
(define-condition serious-condition (condition) ())
(type-error-datum condition)
(type-error-expected-type condition)))))
+(def!method print-object ((condition type-error) stream)
+ (if *print-escape*
+ (flet ((maybe-string (thing)
+ (ignore-errors
+ (write-to-string thing :lines 1 :readably nil :array nil :pretty t))))
+ (let ((type (maybe-string (type-error-expected-type condition)))
+ (datum (maybe-string (type-error-datum condition))))
+ (if (and type datum)
+ (print-unreadable-object (condition stream :type t)
+ (format stream "~@<expected-type: ~A ~_datum: ~A~:@>" type datum))
+ (call-next-method))))
+ (call-next-method)))
+
;;; not specified by ANSI, but too useful not to have around.
(define-condition simple-style-warning (simple-condition style-warning) ())
(define-condition simple-type-error (simple-condition type-error) ())
+;; Can't have a function called SIMPLE-TYPE-ERROR or TYPE-ERROR...
+(declaim (ftype (sfunction (t t t &rest t) nil) bad-type))
+(defun bad-type (datum type control &rest arguments)
+ (error 'simple-type-error
+ :datum datum
+ :expected-type type
+ :format-control control
+ :format-arguments arguments))
+
(define-condition program-error (error) ())
(define-condition parse-error (error) ())
(define-condition control-error (error) ())
(:report
(lambda (condition stream)
(format stream
- "The function ~S is undefined."
+ "The function ~/sb-impl::print-symbol-with-prefix/ is undefined."
(cell-error-name condition)))))
(define-condition special-form-function (undefined-function) ()
(define-condition simple-reference-warning (reference-condition simple-warning)
())
+(define-condition arguments-out-of-domain-error
+ (arithmetic-error reference-condition)
+ ())
+
(define-condition duplicate-definition (reference-condition warning)
((name :initarg :name :reader duplicate-definition-name))
(:report (lambda (c s)
'(:ansi-cl :function make-array)
'(:ansi-cl :function sb!xc:upgraded-array-element-type))))
-(define-condition displaced-to-array-too-small-error
- (reference-condition simple-error)
- ()
- (:default-initargs
- :references (list '(:ansi-cl :function adjust-array))))
-
(define-condition type-warning (reference-condition simple-warning)
()
(:default-initargs :references (list '(:sbcl :node "Handling of Types"))))
+(define-condition type-style-warning (reference-condition simple-style-warning)
+ ()
+ (:default-initargs :references (list '(:sbcl :node "Handling of Types"))))
(define-condition local-argument-mismatch (reference-condition simple-warning)
()
"No traps are enabled? How can this be?"
stream))))))
+(define-condition invalid-array-index-error (type-error)
+ ((array :initarg :array :reader invalid-array-index-error-array)
+ (axis :initarg :axis :reader invalid-array-index-error-axis))
+ (:report
+ (lambda (condition stream)
+ (let ((array (invalid-array-index-error-array condition)))
+ (format stream "Index ~W out of bounds for ~@[axis ~W of ~]~S, ~
+ should be nonnegative and <~W."
+ (type-error-datum condition)
+ (when (> (array-rank array) 1)
+ (invalid-array-index-error-axis condition))
+ (type-of array)
+ ;; Extract the bound from (INTEGER 0 (BOUND))
+ (caaddr (type-error-expected-type condition)))))))
+
+(define-condition invalid-array-error (reference-condition type-error) ()
+ (:report
+ (lambda (condition stream)
+ (let ((*print-array* nil))
+ (format stream
+ "~@<Displaced array originally of type ~S has been invalidated ~
+ due its displaced-to array ~S having become too small to hold ~
+ it: the displaced array's dimensions have all been set to zero ~
+ to trap accesses to it.~:@>"
+ (type-error-expected-type condition)
+ (array-displacement (type-error-datum condition))))))
+ (:default-initargs
+ :references
+ (list '(:ansi-cl :function adjust-array))))
+
(define-condition index-too-large-error (type-error)
()
(:report
(simple-condition-format-arguments condition)
(reader-impossible-number-error-error condition))))))
+(define-condition standard-readtable-modified-error (reference-condition error)
+ ((operation :initarg :operation :reader standard-readtable-modified-operation))
+ (:report (lambda (condition stream)
+ (format stream "~S would modify the standard readtable."
+ (standard-readtable-modified-operation condition))))
+ (:default-initargs :references `((:ansi-cl :section (2 1 1 2))
+ (:ansi-cl :glossary "standard readtable"))))
+
+(define-condition standard-pprint-dispatch-table-modified-error
+ (reference-condition error)
+ ((operation :initarg :operation
+ :reader standard-pprint-dispatch-table-modified-operation))
+ (:report (lambda (condition stream)
+ (format stream "~S would modify the standard pprint dispatch table."
+ (standard-pprint-dispatch-table-modified-operation
+ condition))))
+ (:default-initargs
+ :references `((:ansi-cl :glossary "standard pprint dispatch table"))))
+
(define-condition timeout (serious-condition)
((seconds :initarg :seconds :initform nil :reader timeout-seconds))
(:report (lambda (condition stream)
(lambda (condition stream)
(declare (type stream stream))
(format stream
- "I/O timeout ~(~A~)ing ~S."
+ "I/O timeout while doing ~(~A~) on ~S."
(io-timeout-direction condition)
(stream-error-stream condition)))))
Associated with this condition are always the restarts STEP-INTO,
STEP-NEXT, and STEP-CONTINUE."))
-#!+sb-doc
-(setf (fdocumentation 'step-condition-source-path 'function)
- "Source-path of the original form associated with the
-STEP-FORM-CONDITION or NIL."
- (fdocumentation 'step-condition-pathname 'function)
- "Pathname of the original source-file associated with the
-STEP-FORM-CONDITION or NIL.")
-
(define-condition step-result-condition (step-condition)
((result :initarg :result :reader step-condition-result)))
(new-location :initarg :new-location
:reader redefinition-with-defun-new-location))
(:report (lambda (warning stream)
- (format stream "redefining ~S in DEFUN"
+ (format stream "redefining ~/sb-impl::print-symbol-with-prefix/ ~
+ in DEFUN"
(function-redefinition-warning-name warning)))))
(define-condition redefinition-with-defgeneric (function-redefinition-warning)
((new-location :initarg :new-location
:reader redefinition-with-defgeneric-new-location))
(:report (lambda (warning stream)
- (format stream "redefining ~S in DEFGENERIC"
+ (format stream "redefining ~/sb-impl::print-symbol-with-prefix/ ~
+ in DEFGENERIC"
(function-redefinition-warning-name warning)))))
(define-condition redefinition-with-defmethod (redefinition-warning)
(proclamation-mismatch-name warning)
(proclamation-mismatch-old warning)))))
\f
+;;;; deprecation conditions
+
+(define-condition deprecation-condition ()
+ ((name :initarg :name :reader deprecated-name)
+ (replacement :initarg :replacement :reader deprecated-name-replacement)
+ (since :initarg :since :reader deprecated-since)
+ (runtime-error :initarg :runtime-error :reader deprecated-name-runtime-error)))
+
+(def!method print-object ((condition deprecation-condition) stream)
+ (let ((*package* (find-package :keyword)))
+ (if *print-escape*
+ (print-unreadable-object (condition stream :type t)
+ (format stream "~S is deprecated~@[, use ~S~]"
+ (deprecated-name condition)
+ (deprecated-name-replacement condition)))
+ (format stream "~@<~S has been deprecated as of SBCL ~A~
+ ~@[, use ~S instead~].~:@>"
+ (deprecated-name condition)
+ (deprecated-since condition)
+ (deprecated-name-replacement condition)))))
+
+(define-condition early-deprecation-warning (style-warning deprecation-condition)
+ ())
+
+(def!method print-object :after ((warning early-deprecation-warning) stream)
+ (unless *print-escape*
+ (let ((*package* (find-package :keyword)))
+ (format stream "~%~@<~:@_In future SBCL versions ~S will signal a full warning ~
+ at compile-time.~:@>"
+ (deprecated-name warning)))))
+
+(define-condition late-deprecation-warning (warning deprecation-condition)
+ ())
+
+(def!method print-object :after ((warning late-deprecation-warning) stream)
+ (unless *print-escape*
+ (when (deprecated-name-runtime-error warning)
+ (let ((*package* (find-package :keyword)))
+ (format stream "~%~@<~:@_In future SBCL versions ~S will signal a runtime error.~:@>"
+ (deprecated-name warning))))))
+
+(define-condition final-deprecation-warning (warning deprecation-condition)
+ ())
+
+(def!method print-object :after ((warning final-deprecation-warning) stream)
+ (unless *print-escape*
+ (when (deprecated-name-runtime-error warning)
+ (let ((*package* (find-package :keyword)))
+ (format stream "~%~@<~:@_An error will be signaled at runtime for ~S.~:@>"
+ (deprecated-name warning))))))
+
+(define-condition deprecation-error (error deprecation-condition)
+ ())
+\f
;;;; restart definitions
(define-condition abort-failure (control-error) ()