From 21104e6808a4496afb8163d92c6fb4d59e3010b7 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Mon, 30 Nov 2020 23:46:48 +0100 Subject: [PATCH] Fix `comp-mvar-symbol-p' and `comp-mvar-cons-p' (bug#44968) * lisp/emacs-lisp/comp.el (comp-mvar-symbol-p): As all slots into a `comp-cstr' are in or fix this logic. (comp-mvar-cons-p): Likewise. * test/src/comp-tests.el (bug-44968): New testcase. * test/src/comp-test-funcs.el (comp-test-44968-f): New test function. --- lisp/emacs-lisp/comp.el | 12 +++++++++--- test/src/comp-test-funcs.el | 10 ++++++++++ test/src/comp-tests.el | 4 ++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 498aae183a5..13f9beb5f96 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -550,12 +550,18 @@ CFG is mutated by a pass.") (defun comp-mvar-symbol-p (mvar) "Return t if MVAR is certainly a symbol." - (or (equal (comp-mvar-typeset mvar) '(symbol)) - (cl-every #'symbolp (comp-mvar-valset mvar)))) + (and (null (comp-mvar-range mvar)) + (or (and (null (comp-mvar-valset mvar)) + (equal (comp-mvar-typeset mvar) '(symbol))) + (and (or (null (comp-mvar-typeset mvar)) + (equal (comp-mvar-typeset mvar) '(symbol))) + (cl-every #'symbolp (comp-mvar-valset mvar)))))) (defsubst comp-mvar-cons-p (mvar) "Return t if MVAR is certainly a cons." - (equal (comp-mvar-typeset mvar) '(cons))) + (and (null (comp-mvar-valset mvar)) + (null (comp-mvar-range mvar)) + (equal (comp-mvar-typeset mvar) '(cons)))) (defun comp-mvar-type-hint-match-p (mvar type-hint) "Match MVAR against TYPE-HINT. diff --git a/test/src/comp-test-funcs.el b/test/src/comp-test-funcs.el index 207b6455f73..5fa427be190 100644 --- a/test/src/comp-test-funcs.el +++ b/test/src/comp-test-funcs.el @@ -380,6 +380,16 @@ it nil))) +(defun comp-test-44968-f (start end) + (let ((dirlist) + (dir (expand-file-name start)) + (end (expand-file-name end))) + (while (not (or (equal dir (car dirlist)) + (file-equal-p dir end))) + (push dir dirlist) + (setq dir (directory-file-name (file-name-directory dir)))) + (nreverse dirlist))) + ;;;;;;;;;;;;;;;;;;;; ;; Tromey's tests ;; diff --git a/test/src/comp-tests.el b/test/src/comp-tests.el index dd97ccd5bd1..c2af52e4cab 100644 --- a/test/src/comp-tests.el +++ b/test/src/comp-tests.el @@ -391,6 +391,10 @@ https://lists.gnu.org/archive/html/bug-gnu-emacs/2020-03/msg00914.html." (should (string= (comp-test-42360-f "Nel mezzo del " 18 0 32 "yyy" nil) "Nel mezzo del yyy"))) +(comp-deftest bug-44968 () + "" + (comp-test-44968-f "/tmp/test/foo" "/tmp")) + (defvar comp-test-primitive-advice) (comp-deftest primitive-advice () "Test effectiveness of primitive advicing." -- 2.39.5