Subject: bug#34781: Acknowledgement (27.0.50; integer in pcase sometimes compared by eq)

From: Mattias Engdegård <[email-masked]>
Date: Tue, 12 Mar 2019 13:24:41 +0100

Tags: patch

Complete patch with test case.

From b156563ce680f2f63cf57e976f2416d53a94ab4e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= <[email-masked]>
Date: Tue, 12 Mar 2019 13:19:35 +0100
Subject: [PATCH] Don't match bignums with `memq' in `pcase'

* lisp/emacs-lisp/pcase.el (pcase--u1):
Use fixnump instead of integerp as criterion for memq (Bug#34781).
* test/lisp/emacs-lisp/pcase-tests.el (pcase-tests-member): Test the above.
---
 lisp/emacs-lisp/pcase.el            | 2 +-
 test/lisp/emacs-lisp/pcase-tests.el | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el
index 9de2401549..c26a3d7708 100644
--- a/lisp/emacs-lisp/pcase.el
+++ b/lisp/emacs-lisp/pcase.el
@@ -792,7 +792,7 @@ pcase--u1
                    (let ((upat (cddr alt)))
                      (eq (car-safe upat) 'quote)))
               (let ((val (cadr (cddr alt))))
-                (unless (or (integerp val) (symbolp val))
+                (unless (or (fixnump val) (symbolp val))
                   (setq memq-ok nil))
                 (push (cadr (cddr alt)) simples))
             (push alt others))))
diff --git a/test/lisp/emacs-lisp/pcase-tests.el b/test/lisp/emacs-lisp/pcase-tests.el
index 1e9d37fbfa..a7c66dbf1e 100644
--- a/test/lisp/emacs-lisp/pcase-tests.el
+++ b/test/lisp/emacs-lisp/pcase-tests.el
@@ -56,6 +56,12 @@ pcase-tests-grep
            'member (macroexpand-all '(pcase x ((or "a" 2 3) body)))))
   (should-not (pcase-tests-grep
                'memq (macroexpand-all '(pcase x ((or "a" 2 3) body)))))
+  (should (pcase-tests-grep
+           'member (macroexpand-all '(pcase x ((or #x10000000000000000 2 3)
+                                               body)))))
+  (should-not (pcase-tests-grep
+               'memq (macroexpand-all '(pcase x ((or #x10000000000000000 2 3)
+                                                 body)))))
   (let ((exp (macroexpand-all
                       '(pcase x
                          ("a" body1)
-- 
2.20.1