diff options
| author | Andrea Corallo | 2021-03-06 22:36:50 +0100 |
|---|---|---|
| committer | Andrea Corallo | 2021-03-06 23:17:14 +0100 |
| commit | c60f2f458a63a8ae4288652228f24e43fdc7bba7 (patch) | |
| tree | bdd1f91cbff403ac013e2eeb02dd837d1b3a14a6 | |
| parent | 6c73418c95ae5aca7e63d8d5703a90e178350527 (diff) | |
| download | emacs-c60f2f458a63a8ae4288652228f24e43fdc7bba7.tar.gz emacs-c60f2f458a63a8ae4288652228f24e43fdc7bba7.zip | |
Fix `comp-cstr-intersection-no-hashcons' for negated result cstr
* lisp/emacs-lisp/comp-cstr.el
(comp-cstr-intersection-no-hashcons): When negated and
necessary relax dst to t.
* test/src/comp-tests.el (comp-tests-type-spec-tests): Add a test.
| -rw-r--r-- | lisp/emacs-lisp/comp-cstr.el | 32 | ||||
| -rw-r--r-- | test/src/comp-tests.el | 9 |
2 files changed, 27 insertions, 14 deletions
diff --git a/lisp/emacs-lisp/comp-cstr.el b/lisp/emacs-lisp/comp-cstr.el index d6423efa0d6..4397a914981 100644 --- a/lisp/emacs-lisp/comp-cstr.el +++ b/lisp/emacs-lisp/comp-cstr.el | |||
| @@ -1001,20 +1001,26 @@ promoted to their types. | |||
| 1001 | DST is returned." | 1001 | DST is returned." |
| 1002 | (with-comp-cstr-accessors | 1002 | (with-comp-cstr-accessors |
| 1003 | (apply #'comp-cstr-intersection dst srcs) | 1003 | (apply #'comp-cstr-intersection dst srcs) |
| 1004 | (let (strip-values strip-types) | 1004 | (if (and (neg dst) |
| 1005 | (cl-loop for v in (valset dst) | 1005 | (valset dst) |
| 1006 | unless (or (symbolp v) | 1006 | (cl-notevery #'symbolp (valset dst))) |
| 1007 | (fixnump v)) | 1007 | (setf (valset dst) () |
| 1008 | do (push v strip-values) | 1008 | (typeset dst) '(t) |
| 1009 | (push (type-of v) strip-types)) | 1009 | (range dst) () |
| 1010 | (when strip-values | 1010 | (neg dst) nil) |
| 1011 | (setf (typeset dst) (comp-union-typesets (typeset dst) strip-types) | 1011 | (let (strip-values strip-types) |
| 1012 | (valset dst) (cl-set-difference (valset dst) strip-values))) | 1012 | (cl-loop for v in (valset dst) |
| 1013 | (cl-loop for (l . h) in (range dst) | 1013 | unless (symbolp v) |
| 1014 | when (or (bignump l) (bignump h)) | 1014 | do (push v strip-values) |
| 1015 | (push (type-of v) strip-types)) | ||
| 1016 | (when strip-values | ||
| 1017 | (setf (typeset dst) (comp-union-typesets (typeset dst) strip-types) | ||
| 1018 | (valset dst) (cl-set-difference (valset dst) strip-values))) | ||
| 1019 | (cl-loop for (l . h) in (range dst) | ||
| 1020 | when (or (bignump l) (bignump h)) | ||
| 1015 | do (setf (range dst) '((- . +))) | 1021 | do (setf (range dst) '((- . +))) |
| 1016 | (cl-return)) | 1022 | (cl-return)))) |
| 1017 | dst))) | 1023 | dst)) |
| 1018 | 1024 | ||
| 1019 | (defun comp-cstr-intersection-make (&rest srcs) | 1025 | (defun comp-cstr-intersection-make (&rest srcs) |
| 1020 | "Combine SRCS by intersection set operation and return a new constraint." | 1026 | "Combine SRCS by intersection set operation and return a new constraint." |
diff --git a/test/src/comp-tests.el b/test/src/comp-tests.el index cd1c2e0735e..f60e4ab0497 100644 --- a/test/src/comp-tests.el +++ b/test/src/comp-tests.el | |||
| @@ -1340,7 +1340,14 @@ Return a list of results." | |||
| 1340 | (unless (eql x -0.0) | 1340 | (unless (eql x -0.0) |
| 1341 | (error "")) | 1341 | (error "")) |
| 1342 | x) | 1342 | x) |
| 1343 | float))) | 1343 | float) |
| 1344 | |||
| 1345 | ;; 73 | ||
| 1346 | ((defun comp-tests-ret-type-spec-f (x) | ||
| 1347 | (when (eql x 1.0) | ||
| 1348 | (error "")) | ||
| 1349 | x) | ||
| 1350 | t))) | ||
| 1344 | 1351 | ||
| 1345 | (defun comp-tests-define-type-spec-test (number x) | 1352 | (defun comp-tests-define-type-spec-test (number x) |
| 1346 | `(comp-deftest ,(intern (format "ret-type-spec-%d" number)) () | 1353 | `(comp-deftest ,(intern (format "ret-type-spec-%d" number)) () |