[Git][cmucl/cmucl][master] 2 commits: Fix #58: Bogus type error in comparison of complex number with `THE` form

Raymond Toy rtoy at common-lisp.net
Sun Feb 18 17:11:21 UTC 2018


Raymond Toy pushed to branch master at cmucl / cmucl


Commits:
bccd6a98 by Raymond Toy at 2018-02-18T09:01:08-08:00
Fix #58: Bogus type error in comparison of complex number with `THE` form

The deftransforms `upgraded-complex-real-contagion-arg1` and
`upgraded-complex-real-contagion-arg2` were coercing the complex
number to the exact type of the float number.  Because of the `THE`
form, the type of the float was `(member 1d0)`, so the compiler was
coercing `#c(1/2 1/2)` to `(complex (double-float 1d0))`, which is
wrong.

Therefore, coerce the complex to just the type format of the real
part, ignoring any bounds.

* src/compiler/float-tran.lisp
  * Coerce to format type, discarding any bounds
* src/general-info/release-21d.md
  * Update notes
* tests/issues.lisp
  * Added test for this

- - - - -
771fd903 by Raymond Toy at 2018-02-18T17:11:19+00:00
Merge branch 'rtoy-fix-issue-58' into 'master'

Fix #58: Bogus type error in comparison of complex number with `THE` form

Closes #58

See merge request cmucl/cmucl!37
- - - - -


3 changed files:

- src/compiler/float-tran.lisp
- src/general-info/release-21d.md
- tests/issues.lisp


Changes:

=====================================
src/compiler/float-tran.lisp
=====================================
--- a/src/compiler/float-tran.lisp
+++ b/src/compiler/float-tran.lisp
@@ -1903,7 +1903,7 @@
 (deftransform upgraded-complex-real-contagion-arg1 ((x y) * * :defun-only t :node node)
   ;;(format t "upgraded-complex-real-contagion-arg1~%")
   `(,(continuation-function-name (basic-combination-fun node))
-     (coerce x '(complex ,(type-specifier (continuation-type y))))
+     (coerce x '(complex ,(numeric-type-format (continuation-type y))))
      y))
 ;;;
 (deftransform upgraded-complex-real-contagion-arg2 ((x y) * * :defun-only t :node node)
@@ -1912,7 +1912,7 @@
 	  (continuation-type x) (continuation-type y))
   `(,(continuation-function-name (basic-combination-fun node))
      x
-     (coerce y '(complex ,(type-specifier (continuation-type x))))))
+     (coerce y '(complex ,(numeric-type-format (continuation-type x))))))
 
 
 (dolist (x '(= + * / -))


=====================================
src/general-info/release-21d.md
=====================================
--- a/src/general-info/release-21d.md
+++ b/src/general-info/release-21d.md
@@ -34,6 +34,7 @@ public domain.
     * ~~#47~~ Backquate and multiple splices
     * ~~#59~~ Incorrect type-derivation for `decode-float`
     * ~~#60~~ The function `C::%UNARY-FROUND` is undefined
+    * ~~#58~~ Bogus type error in comparison of complex number with `THE` form
   * Other changes:
   * Improvements to the PCL implementation of CLOS:
   * Changes to building procedure:


=====================================
tests/issues.lisp
=====================================
--- a/tests/issues.lisp
+++ b/tests/issues.lisp
@@ -515,3 +515,9 @@
     (assert-equalp
      (values 2d0 0d0)
      (funcall c14 2d0))))
+
+(define-test issue.58
+  (:tag :issues)
+  (let ((c9 (compile nil #'(lambda (x)
+			     (= (the (eql 1.0d0) x) #c(1/2 1/2))))))
+    (assert-false (funcall c9 1.d0))))



View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/compare/31c6bf9faef2ce24d42d5af0bea8e2d103912563...771fd903423d15380c445426f72995735727f4d5

---
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/compare/31c6bf9faef2ce24d42d5af0bea8e2d103912563...771fd903423d15380c445426f72995735727f4d5
You're receiving this email because of your account on gitlab.common-lisp.net.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cmucl-cvs/attachments/20180218/dc989eb8/attachment-0001.html>


More information about the cmucl-cvs mailing list