Compute single-value-type correctly in the absence of required values
authorPaul Khuong <pvk@pvk.ca>
Mon, 27 May 2013 21:38:15 +0000 (17:38 -0400)
committerPaul Khuong <pvk@pvk.ca>
Mon, 27 May 2013 21:45:33 +0000 (17:45 -0400)
 * For the longest time (at least 2003), we didn't take defaulting
   into account and did not union the single-value type with NULL.
   For some reason, the issue didn't manigest itself until we improved
   code generation for EQ/EQL this month.

   Thanks to Attila Lendvai for the reasonable test case.

 * Also, fix a typo in a VOP name for EQ of fixnum values.

src/code/late-type.lisp
src/compiler/x86-64/pred.lisp
src/compiler/x86/pred.lisp
tests/type.pure.lisp

index 481a843..cf7e9a0 100644 (file)
          *empty-type*)
         ((not (values-type-p type))
          type)
-        (t (or (car (args-type-required type))
-               (car (args-type-optional type))
-               (args-type-rest type)
-               (specifier-type 'null)))))
+        ((car (args-type-required type)))
+        (t (type-union (specifier-type 'null)
+                       (or (car (args-type-optional type))
+                           (args-type-rest type)
+                           (specifier-type 'null))))))
 
 ;;; Return the minimum number of arguments that a function can be
 ;;; called with, and the maximum number or NIL. If not a function
index 11eab96..a490a0a 100644 (file)
   (def fast-if-eq-character fast-char=/character)
   (def fast-if-eq-character/c fast-char=/character/c)
   (def fast-if-eq-fixnum fast-eql/fixnum)
-  (def fast-if-eq-fixnum/x fast-eql-c/fixnum)
+  (def fast-if-eq-fixnum/c fast-eql-c/fixnum)
   (def fast-if-eq/signed fast-if-eql/signed)
   (def fast-if-eq-c/signed fast-if-eql-c/signed)
   (def fast-if-eq/unsigned fast-if-eql/unsigned)
index c041603..1843fe3 100644 (file)
   (def fast-if-eq-character fast-char=/character)
   (def fast-if-eq-character/c fast-char=/character/c)
   (def fast-if-eq-fixnum fast-eql/fixnum)
-  (def fast-if-eq-fixnum/x fast-eql-c/fixnum)
+  (def fast-if-eq-fixnum/c fast-eql-c/fixnum)
   (def fast-if-eq/signed fast-if-eql/signed)
   (def fast-if-eq-c/signed fast-if-eql-c/signed)
   (def fast-if-eq/unsigned fast-if-eql/unsigned)
index fff2114..31a7edd 100644 (file)
   (assert (subtypep `(rational * -1/2)
                     `(or (integer * -1)
                          (and (rational * -1/2) (not integer))))))
+
+;; for the longest time (at least 05525d3a), single-value-type would
+;; return CHARACTER on this.
+(with-test (:name :single-value-&optional-type)
+  (assert (sb-c::type= (sb-c::single-value-type
+                        (sb-c::values-specifier-type '(values &optional character)))
+                       (sb-c::specifier-type '(or null character)))))