summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/comp.el
diff options
context:
space:
mode:
authorAndrea Corallo <akrl@sdf.org>2020-12-29 17:39:15 +0100
committerAndrea Corallo <akrl@sdf.org>2020-12-29 17:49:30 +0100
commit3f00d666e9674ba18f1ded490a27ac2868a32a88 (patch)
tree02c438c76ac36a2a2077b8015a78376a9e9c8118 /lisp/emacs-lisp/comp.el
parenta3b816ff8ce17ec559043b053e60b631e5dc5eb8 (diff)
downloademacs-3f00d666e9674ba18f1ded490a27ac2868a32a88.tar.gz
emacs-3f00d666e9674ba18f1ded490a27ac2868a32a88.tar.bz2
emacs-3f00d666e9674ba18f1ded490a27ac2868a32a88.zip
Fix missing negation handling in a bunch of predicates
* lisp/emacs-lisp/comp.el (comp-mvar-fixnum-p) (comp-mvar-symbol-p, comp-mvar-cons-p): Consider neg slot. * test/src/comp-tests.el (comp-test-not-cons): New test. * test/src/comp-test-funcs.el (comp-test-not-cons-f): New function.
Diffstat (limited to 'lisp/emacs-lisp/comp.el')
-rw-r--r--lisp/emacs-lisp/comp.el21
1 files changed, 13 insertions, 8 deletions
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index b885ff88411..bf266256f70 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -538,6 +538,8 @@ CFG is mutated by a pass.")
(integerp high)
(= low high))))))))
+;; FIXME move these into cstr?
+
(defun comp-mvar-value (mvar)
"Return the constant value of MVAR.
`comp-mvar-value-vld-p' *must* be satisfied before calling
@@ -556,18 +558,20 @@ CFG is mutated by a pass.")
(defun comp-mvar-fixnum-p (mvar)
"Return t if MVAR is certainly a fixnum."
- (when-let (range (comp-mvar-range mvar))
- (let* ((low (caar range))
- (high (cdar (last range))))
- (unless (or (eq low '-)
- (< low most-negative-fixnum)
- (eq high '+)
- (> high most-positive-fixnum))
- t))))
+ (when (null (comp-mvar-neg mvar))
+ (when-let (range (comp-mvar-range mvar))
+ (let* ((low (caar range))
+ (high (cdar (last range))))
+ (unless (or (eq low '-)
+ (< low most-negative-fixnum)
+ (eq high '+)
+ (> high most-positive-fixnum))
+ t)))))
(defun comp-mvar-symbol-p (mvar)
"Return t if MVAR is certainly a symbol."
(and (null (comp-mvar-range mvar))
+ (null (comp-mvar-neg mvar))
(or (and (null (comp-mvar-valset mvar))
(equal (comp-mvar-typeset mvar) '(symbol)))
(and (or (null (comp-mvar-typeset mvar))
@@ -578,6 +582,7 @@ CFG is mutated by a pass.")
"Return t if MVAR is certainly a cons."
(and (null (comp-mvar-valset mvar))
(null (comp-mvar-range mvar))
+ (null (comp-mvar-neg mvar))
(equal (comp-mvar-typeset mvar) '(cons))))
(defun comp-mvar-type-hint-match-p (mvar type-hint)