+;;; bug 31 turned out to be a manifestation of non-ANSI array type
+;;; handling, fixed by CSR in sbcl-0.7.3.8.
+(defun array-element-type-handling (x)
+ (declare (optimize safety))
+ (declare (type (vector cons) x))
+ (when (consp (aref x 0))
+ (aref x 0)))
+(assert (raises-error?
+ (array-element-type-handling
+ (make-array 3 :element-type t :initial-element 0))
+ type-error))
+
+;;; bug 220: type check inserted after all arguments in MV-CALL caused
+;;; failure of stack analysis
+(defun bug220-helper ()
+ 13)
+(assert (equal (multiple-value-call #'list
+ (the integer (bug220-helper))
+ nil)
+ '(13 nil)))
+
+;;; bug 221: sbcl 0.7.9.13 failed to compile the following function
+(declaim (ftype (function (fixnum) (values package boolean)) bug221-f1))
+(declaim (ftype (function (t) (values package boolean)) bug221-f2))
+(defun bug221 (b x)
+ (funcall (if b #'bug221-f1 #'bug221-f2) x))
+
+;;; bug 166: compiler failure
+(defstruct bug166s)
+(defmethod permanentize ((uustk bug166s))
+ (flet ((frob (hash-table test-for-deletion)
+ )
+ (obj-entry.stale? (oe)
+ (destructuring-bind (key . datum) oe
+ (declare (type simple-vector key))
+ (deny0 (void? datum))
+ (some #'stale? key))))
+ (declare (inline frob obj-entry.stale?))
+ (frob (uustk.args-hash->obj-alist uustk)
+ #'obj-entry.stale?)
+ (frob (uustk.hash->memoized-objs-list uustk)
+ #'objs.stale?))
+ (call-next-method))
+
+;;; bugs 115, 226: compiler failure in lifetime analysis
+(defun bug115-1 ()
+ (declare (optimize (speed 2) (debug 3)))
+ (flet ((m1 ()
+ (unwind-protect nil)))
+ (if (catch nil)
+ (m1)
+ (m1))))
+
+(defun bug115-2 ()
+ (declare (optimize (speed 2) (debug 3)))
+ (flet ((m1 ()
+ (bar (if (foo) 1 2))
+ (let ((x (foo)))
+ (bar x (list x)))))
+ (if (catch nil)
+ (m1)
+ (m1))))
+
+(defun bug226 ()
+ (declare (optimize (speed 0) (safety 3) (debug 3)))
+ (flet ((safe-format (stream string &rest r)
+ (unless (ignore-errors (progn
+ (apply #'format stream string r)
+ t))
+ (format stream "~&foo ~S" string))))
+ (cond
+ ((eq my-result :ERROR)
+ (cond
+ ((ignore-errors (typep condition result))
+ (safe-format t "~&bar ~S" result))
+ (t
+ (safe-format t "~&baz ~S (~A) ~S" condition condition result)))))))
+
+;;; bug 231: SETQ did not check the type of the variable being set
+(defun bug231a-1 (x)
+ (declare (optimize safety) (type (integer 0 8) x))
+ (incf x))
+(assert (raises-error? (bug231a-1 8) type-error))
+
+(defun bug231a-2 (x)
+ (declare (optimize safety) (type (integer 0 8) x))
+ (list (lambda (y) (setq x y))
+ (lambda () x)))
+(destructuring-bind (set get) (bug231a-2 0)
+ (funcall set 8)
+ (assert (eql (funcall get) 8))
+ (assert (raises-error? (funcall set 9) type-error))
+ (assert (eql (funcall get) 8)))
+
+(defun bug231b (x z)
+ (declare (optimize safety) (type integer x))
+ (locally
+ (declare (type (real 1) x))
+ (setq x z))
+ (list x z))
+(assert (raises-error? (bug231b nil 1) type-error))
+(assert (raises-error? (bug231b 0 1.5) type-error))
+(assert (raises-error? (bug231b 0 0) type-error))
+
+;;; A bug appeared in flaky7_branch. Python got lost in unconverting
+;;; embedded tail calls during let-conversion.
+(defun bug239 (bit-array-2 &optional result-bit-array)
+ (declare (type (array bit) bit-array-2)
+ (type (or (array bit) (member t nil)) result-bit-array))
+ (unless (simple-bit-vector-p bit-array-2)
+ (multiple-value-call
+ (lambda (data1 start1)
+ (multiple-value-call
+ (lambda (data2 start2)
+ (multiple-value-call
+ (lambda (data3 start3)
+ (declare (ignore start3))
+ (print (list data1 data2)))
+ (values 0 0)))
+ (values bit-array-2 0)))
+ (values 444 0))))
+(assert (equal (bug239 (make-array 4 :element-type 'bit
+ :adjustable t
+ :initial-element 0)
+ nil)
+ '(444 #*0000)))
+
+(defstruct some-structure a)
+(eval-when (:compile-toplevel)
+ ;; in the big CLASS reorganization in pre8, this would fail with
+ ;; SOME-STRUCTURE-A is not FBOUNDP. Fixed in 0.pre8.64
+ (find-class 'some-structure nil))
+(eval-when (:load-toplevel)
+ (assert (typep (find-class 'some-structure) 'class)))