master: Don't put bounds into the complex type for (complex float)
stassats via Sbcl-commits <[email protected]>
| Newsgroups | gmane.lisp.steel-bank.cvs |
|---|---|
| Message-ID | <[email protected]> |
The branch "master" has been updated in SBCL:
via ce88d7209f22005baaa28ea2e8e7fbd96ee0da13 (commit)
from 56b8cb391b9956532d675f94720e48081f4285d9 (commit)
- Log -----------------------------------------------------------------
commit ce88d7209f22005baaa28ea2e8e7fbd96ee0da13
Author: Stas Boukarev <[email protected]>
Date: Wed Apr 8 19:17:09 2026 +0300
Don't put bounds into the complex type for (complex float)
Not only complex parts are now upgraded to exclude bounds, the derived
bound was not correct for imagpart.
---
src/compiler/constraint.lisp | 4 +---
src/compiler/float-tran.lisp | 4 +---
src/compiler/srctran.lisp | 10 +++-------
tests/float-2.pure.lisp | 6 ++++++
4 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/src/compiler/constraint.lisp b/src/compiler/constraint.lisp
index 4f9b92b8a..46f977b0c 100644
--- a/src/compiler/constraint.lisp
+++ b/src/compiler/constraint.lisp
@@ -1155,9 +1155,7 @@
(type-intersection current-type
(type-union (make-numeric-type :low lo
:high hi)
- (make-numeric-type :complexp :complex
- :low lo
- :high hi)))))))
+ (specifier-type 'complex)))))))
(t
(multiple-value-bind (greater equal)
(if not-p
diff --git a/src/compiler/float-tran.lisp b/src/compiler/float-tran.lisp
index 33b8ac2e3..c809e6a37 100644
--- a/src/compiler/float-tran.lisp
+++ b/src/compiler/float-tran.lisp
@@ -1368,9 +1368,7 @@
:complexp (if (csubtypep re-type
(specifier-type 'rational))
:real
- :complex)
- :low (numeric-type-low re-type)
- :high (numeric-type-high re-type))
+ :complex))
(specifier-type 'complex)))
(defun complex-derive-type-aux-2 (re-type im-type same-arg)
diff --git a/src/compiler/srctran.lisp b/src/compiler/srctran.lisp
index 8031b83f6..fba418568 100644
--- a/src/compiler/srctran.lisp
+++ b/src/compiler/srctran.lisp
@@ -3391,13 +3391,10 @@
((eq (numeric-type-complexp type) :complex)
(let* ((format (case (numeric-type-class type)
((integer rational) 'single-float)
- (t (numeric-type-format type))))
- (bound-format (or format 'float)))
+ (t (numeric-type-format type)))))
(make-numeric-type :class 'float
:format format
- :complexp :complex
- :low (coerce -1 bound-format)
- :high (coerce 1 bound-format))))
+ :complexp :complex)))
(t
(let* ((interval (numeric-type->interval type))
(range-info (interval-range-info interval))
@@ -3420,8 +3417,7 @@
(t (type-union minus zero plus)))))
(if (eq (numeric-type-complexp type) :real)
result
- (type-union result (make-numeric-type :class 'float
- :complexp :complex))))))))
+ (type-union result (specifier-type '(complex float)))))))))
(defoptimizer (signum derive-type) ((num))
(one-arg-derive-type num #'signum-derive-type-aux))
diff --git a/tests/float-2.pure.lisp b/tests/float-2.pure.lisp
index e63eab18b..676141a1b 100644
--- a/tests/float-2.pure.lisp
+++ b/tests/float-2.pure.lisp
@@ -913,3 +913,9 @@ fractional bits."
((1) (condition 'type-error
(lambda (c)
(= (type-error-datum c) 2))))))
+
+(with-test (:name :one-arg-complex-type)
+ (assert-type (lambda (x)
+ (declare ((single-float 5.0) x))
+ (imagpart (complex x)))
+ single-float))
-----------------------------------------------------------------------
hooks/post-receive
--
SBCL