+;;; Most of this logic may end up belonging in code/late-type.lisp;
+;;; however, here we also need the -OR-GIVE-UP for the transforms, and
+;;; maybe this is just too sloppy for actual type logic. -- CSR,
+;;; 2004-02-18
+(defun array-type-dimensions-or-give-up (type)
+ (typecase type
+ (array-type (array-type-dimensions type))
+ (union-type
+ (let ((types (union-type-types type)))
+ ;; there are at least two types, right?
+ (aver (> (length types) 1))
+ (let ((result (array-type-dimensions-or-give-up (car types))))
+ (dolist (type (cdr types) result)
+ (unless (equal (array-type-dimensions-or-give-up type) result)
+ (give-up-ir1-transform))))))
+ ;; FIXME: intersection type [e.g. (and (array * (*)) (satisfies foo)) ]
+ (t (give-up-ir1-transform))))
+
+(defun conservative-array-type-complexp (type)
+ (typecase type
+ (array-type (array-type-complexp type))
+ (union-type
+ (let ((types (union-type-types type)))
+ (aver (> (length types) 1))
+ (let ((result (conservative-array-type-complexp (car types))))
+ (dolist (type (cdr types) result)
+ (unless (eq (conservative-array-type-complexp type) result)
+ (return-from conservative-array-type-complexp :maybe))))))
+ ;; FIXME: intersection type
+ (t :maybe)))
+