From: Christophe Rhodes Date: Fri, 31 Jan 2003 15:08:28 +0000 (+0000) Subject: 0.7.12.14: X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=4704aaa73743e936db4ffaeeb4331b33d58a1acf;p=sbcl.git 0.7.12.14: 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) --- diff --git a/src/code/late-type.lisp b/src/code/late-type.lisp index abb2340..5d3b845 100644 --- a/src/code/late-type.lisp +++ b/src/code/late-type.lisp @@ -1201,12 +1201,23 @@ (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)) @@ -2414,8 +2425,12 @@ (!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))) diff --git a/tests/type.pure.lisp b/tests/type.pure.lisp index a770835..8026733 100644 --- a/tests/type.pure.lisp +++ b/tests/type.pure.lisp @@ -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 @@ -117,17 +118,7 @@ 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 diff --git a/version.lisp-expr b/version.lisp-expr index 145255d..efe04d3 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -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"