0.7.12.14:
authorChristophe Rhodes <csr21@cam.ac.uk>
Fri, 31 Jan 2003 15:08:28 +0000 (15:08 +0000)
committerChristophe Rhodes <csr21@cam.ac.uk>
Fri, 31 Jan 2003 15:08:28 +0000 (15:08 +0000)
Type system fixes (thanks to Paul Dietz for the report)
... make the intersection of negation types with non-hairy types
smarter, by considering the type relationship of the
negation (e.g. (AND BASE-CHAR (NOT BASE-CHAR)) and
(AND FIXNUM (NOT INTEGER)) should both be canonicalized
to NIL).
... if either of the CAR-type or CDR-type of a CONS type is NIL,
then the whole type must be NIL too.
(also fixes the unparse of EXTENDED-CHAR)

src/code/late-type.lisp
tests/type.pure.lisp
version.lisp-expr

index abb2340..5d3b845 100644 (file)
   (declare (ignore type1 type2))
   (values nil nil))
 
-(!define-type-method (hairy :simple-intersection2 :complex-intersection2)
+(!define-type-method (hairy :simple-intersection2) 
                     (type1 type2)
   (if (type= type1 type2)
       type1
       nil))
 
+(!define-type-method (hairy :complex-intersection2)
+                    (type1 type2)
+  (aver (hairy-type-p type2))
+  (let ((hairy-type-spec (type-specifier type2)))
+    (if (and (consp hairy-type-spec)
+            (eq (car hairy-type-spec) 'not))
+       (if (csubtypep type1 (specifier-type (cadr hairy-type-spec)))
+           *empty-type*
+           nil)
+       nil)))
+       
 (!define-type-method (hairy :simple-=) (type1 type2)
   (if (equal (hairy-type-specifier type1)
             (hairy-type-specifier type2))
 (!define-type-class cons)
 
 (!def-type-translator cons (&optional (car-type-spec '*) (cdr-type-spec '*))
-  (make-cons-type (specifier-type car-type-spec)
-                 (specifier-type cdr-type-spec)))
+  (let ((car-type (specifier-type car-type-spec))
+       (cdr-type (specifier-type cdr-type-spec)))
+    (if (or (eq car-type *empty-type*)
+           (eq cdr-type *empty-type*))
+       *empty-type*
+       (make-cons-type car-type cdr-type))))
  
 (!define-type-method (cons :unparse) (type)
   (let ((car-eltype (type-specifier (cons-type-car-type type)))
index a770835..8026733 100644 (file)
@@ -33,7 +33,8 @@
 ;;; SINGLE-FLOAT DOUBLE-FLOAT RATIONAL)".  We ideally want all of the
 ;;; defined-by-ANSI types to unparse as themselves or at least
 ;;; something similar (e.g. CHARACTER can unparse to BASE-CHAR, since
-;;; the types are equivalent in current SBCL).
+;;; the types are equivalent in current SBCL, and EXTENDED-CHAR can
+;;; unparse to NIL, since there are no EXTENDED-CHARs currently).
 (let ((standard-types '(;; from table 4-2 in section 4.2.3 in the
                        ;; CLHS.
                        arithmetic-error
                        error
                        readtable
                        two-way-stream
-                       ;; This one's hard: (AND BASE-CHAR (NOT BASE-CHAR))
-                       ;;
-                       ;; This is because it looks like
-                       ;;   (AND CHARACTER (NOT BASE-CHAR))
-                       ;; but CHARACTER is equivalent to
-                       ;; BASE-CHAR. So if we fix intersection of
-                       ;; obviously disjoint types and then do (the
-                       ;; extended-char foo), we'll get back FOO is
-                       ;; not a NIL. -- CSR, 2002-09-16.
-                       ;;
-                       ;; extended-char
+                       extended-char
                        real
                        type-error                 
                        file-error
index 145255d..efe04d3 100644 (file)
@@ -18,4 +18,4 @@
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
 
-"0.7.12.13"
+"0.7.12.14"