From 17dd0a1692d807958a48a10d4cc44fe35cd1d37d Mon Sep 17 00:00:00 2001 From: Paul Khuong Date: Mon, 27 May 2013 17:38:15 -0400 Subject: [PATCH] Compute single-value-type correctly in the absence of required values * 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 | 9 +++++---- src/compiler/x86-64/pred.lisp | 2 +- src/compiler/x86/pred.lisp | 2 +- tests/type.pure.lisp | 7 +++++++ 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/code/late-type.lisp b/src/code/late-type.lisp index 481a843..cf7e9a0 100644 --- a/src/code/late-type.lisp +++ b/src/code/late-type.lisp @@ -451,10 +451,11 @@ *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 diff --git a/src/compiler/x86-64/pred.lisp b/src/compiler/x86-64/pred.lisp index 11eab96..a490a0a 100644 --- a/src/compiler/x86-64/pred.lisp +++ b/src/compiler/x86-64/pred.lisp @@ -273,7 +273,7 @@ (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) diff --git a/src/compiler/x86/pred.lisp b/src/compiler/x86/pred.lisp index c041603..1843fe3 100644 --- a/src/compiler/x86/pred.lisp +++ b/src/compiler/x86/pred.lisp @@ -196,7 +196,7 @@ (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) diff --git a/tests/type.pure.lisp b/tests/type.pure.lisp index fff2114..31a7edd 100644 --- a/tests/type.pure.lisp +++ b/tests/type.pure.lisp @@ -462,3 +462,10 @@ (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))))) -- 1.7.10.4