summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStas Boukarev <stassats@gmail.com>2024-09-29 13:46:02 +0300
committerStas Boukarev <stassats@gmail.com>2024-09-29 23:11:51 +0300
commitbdd8d569741c5a6f4061f1fa9bf429fc6cd6850e (patch)
tree42a5daa484b77e63243a92dbc7a6b262153610df
parent5cbd0e1d9c394fd7e120aa161067db4eeb6fd28c (diff)
Derive that (+ x (complex float)) is a (complex float)
-rw-r--r--src/code/type.lisp6
-rw-r--r--tests/arith-2.pure.lisp10
2 files changed, 13 insertions, 3 deletions
diff --git a/src/code/type.lisp b/src/code/type.lisp
index 0be22a244..7b1065e7d 100644
--- a/src/code/type.lisp
+++ b/src/code/type.lisp
@@ -3490,9 +3490,9 @@ used for a COMPLEX component.~:@>"
:complexp (cond ((and (eq complexp1 :real)
(eq complexp2 :real))
:real)
- ((or (null complexp1) (null complexp2))
- nil)
- (t :complex))))
+ ((or (eq complexp1 :complex)
+ (eq complexp2 :complex))
+ :complex))))
((eq class2 'float) (numeric-contagion type2 type1))
((and (eq complexp1 :real) (eq complexp2 :real))
(if (or rational
diff --git a/tests/arith-2.pure.lisp b/tests/arith-2.pure.lisp
index cc0420bd1..f9d678ef7 100644
--- a/tests/arith-2.pure.lisp
+++ b/tests/arith-2.pure.lisp
@@ -613,3 +613,13 @@
(< a b))
((6 4.0) nil)
((1 1.1) t)))
+
+(with-test (:name :complex+non-complex-type)
+ (assert-type
+ (lambda (a)
+ (+ a #c(1.0 3.0)))
+ (or (complex single-float) (complex double-float)))
+ (assert-type
+ (lambda (a)
+ (* a #c(1d0 0d0)))
+ (complex double-float)))