X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Fcondition.lisp;h=9b68c2b0c317581ef1eba5172c1f2f0461b0f807;hb=722703e7cbd3a4b279a4c1baab5d95df2c23cce9;hp=b0430b4d98bcfec03efeb8bea94eb2e579141a42;hpb=f0f5d9fc9d493e6683852f947293855be46d4750;p=sbcl.git diff --git a/src/code/condition.lisp b/src/code/condition.lisp index b0430b4..9b68c2b 100644 --- a/src/code/condition.lisp +++ b/src/code/condition.lisp @@ -1,8 +1,6 @@ ;;;; stuff originally from CMU CL's error.lisp which can or should ;;;; come late (mostly related to the CONDITION class itself) ;;;; -;;;; FIXME: should perhaps be called condition.lisp, or moved into -;;;; classes.lisp ;;;; This software is part of the SBCL system. See the README file for ;;;; more information. @@ -109,7 +107,7 @@ ;; cold-loadable code. -- WHN 19990928 (declare (notinline sb!xc:find-class)) (find-class 'condition))) - #'(lambda (cond stream) + (lambda (cond stream) (format stream "Condition ~S was signalled." (type-of cond)))) (eval-when (:compile-toplevel :load-toplevel :execute) @@ -118,9 +116,9 @@ (let* ((cpl (remove-duplicates (reverse (reduce #'append - (mapcar #'(lambda (x) - (condition-class-cpl - (sb!xc:find-class x))) + (mapcar (lambda (x) + (condition-class-cpl + (sb!xc:find-class x))) parent-types))))) (cond-layout (info :type :compiler-layout 'condition)) (olayout (info :type :compiler-layout name)) @@ -361,11 +359,11 @@ (let ((name (condition-slot-name slot))) (dolist (reader (condition-slot-readers slot)) (setf (fdefinition reader) - #'(lambda (condition) + (lambda (condition) (condition-reader-function condition name)))) (dolist (writer (condition-slot-writers slot)) (setf (fdefinition writer) - #'(lambda (new-value condition) + (lambda (new-value condition) (condition-writer-function condition new-value name)))))) ;; Compute effective slots and set up the class and hairy slots @@ -715,8 +713,7 @@ (define-condition namestring-parse-error (parse-error) ((complaint :reader namestring-parse-error-complaint :initarg :complaint) - (arguments :reader namestring-parse-error-arguments :initarg :arguments - :initform nil) + (args :reader namestring-parse-error-args :initarg :args :initform nil) (namestring :reader namestring-parse-error-namestring :initarg :namestring) (offset :reader namestring-parse-error-offset :initarg :offset)) (:report @@ -724,7 +721,7 @@ (format stream "parse error in namestring: ~?~% ~A~% ~V@T^" (namestring-parse-error-complaint condition) - (namestring-parse-error-arguments condition) + (namestring-parse-error-args condition) (namestring-parse-error-namestring condition) (namestring-parse-error-offset condition))))) @@ -741,6 +738,69 @@ (stream-error-stream condition) (reader-eof-error-context condition))))) +;;;; special SBCL extension conditions + +;;; an error apparently caused by a bug in SBCL itself +;;; +;;; Note that we don't make any serious effort to use this condition +;;; for *all* errors in SBCL itself. E.g. type errors and array +;;; indexing errors can occur in functions called from SBCL code, and +;;; will just end up as ordinary TYPE-ERROR or invalid index error, +;;; because the signalling code has no good way to know that the +;;; underlying problem is a bug in SBCL. But in the fairly common case +;;; that the signalling code does know that it's found a bug in SBCL, +;;; this condition is appropriate, reusing boilerplate and helping +;;; users to recognize it as an SBCL bug. +(define-condition bug (simple-error) + () + (:report + (lambda (condition stream) + (format stream + "~@< ~? ~:@_~?~:>" + (simple-condition-format-control condition) + (simple-condition-format-arguments condition) + "~@.~:@>" + '((fmakunbound 'compile)))))) +(defun bug (format-control &rest format-arguments) + (error 'bug + :format-control format-control + :format-arguments format-arguments)) + +;;; a condition for use in stubs for operations which aren't supported +;;; on some platforms +;;; +;;; E.g. in sbcl-0.7.0.5, it might be appropriate to do something like +;;; #-(or freebsd linux) +;;; (defun load-foreign (&rest rest) +;;; (error 'unsupported-operator :name 'load-foreign)) +;;; #+(or freebsd linux) +;;; (defun load-foreign ... actual definition ...) +;;; By signalling a standard condition in this case, we make it +;;; possible for test code to distinguish between (1) intentionally +;;; unimplemented and (2) unintentionally just screwed up somehow. +;;; (Before this condition was defined, test code tried to deal with +;;; this by checking for FBOUNDP, but that didn't work reliably. In +;;; sbcl-0.7.0, a a package screwup left the definition of +;;; LOAD-FOREIGN in the wrong package, so it was unFBOUNDP even on +;;; architectures where it was supposed to be supported, and the +;;; regression tests cheerfully passed because they assumed that +;;; unFBOUNDPness meant they were running on an system which didn't +;;; support the extension.) +(define-condition unsupported-operator (cell-error) () + (:report + (lambda (condition stream) + (format stream + "unsupported on this platform (OS, CPU, whatever): ~S" + (cell-error-name condition))))) + ;;;; restart definitions (define-condition abort-failure (control-error) ()