all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#35869: [PATCH] `cl-member' and `cl-assoc' do not work for bignums
@ 2019-05-23 16:01 Mattias Engdegård
  2019-06-02  1:15 ` Paul Eggert
  0 siblings, 1 reply; 3+ messages in thread
From: Mattias Engdegård @ 2019-05-23 16:01 UTC (permalink / raw)
  To: 35869

[-- Attachment #1: Type: text/plain, Size: 136 bytes --]

(cl-member (ash 1 100) (list (ash 1 100))) => nil
(cl-assoc (ash 1 100) (list (cons (ash 1 100) t))) => nil

Suggested patch attached.


[-- Attachment #2: 0001-Fix-cl-member-and-cl-assoc-for-bignums.patch --]
[-- Type: application/octet-stream, Size: 2241 bytes --]

From 6313fdb00b13246305be0218452afefe9e05432c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= <mattiase@acm.org>
Date: Thu, 23 May 2019 17:54:58 +0200
Subject: [PATCH] Fix `cl-member' and `cl-assoc' for bignums

* lisp/emacs-lisp/cl-seq.el (cl-member, cl-assoc): Work with bignums.
* test/lisp/emacs-lisp/cl-seq-tests.el (cl-seq-bignum-eql): New.
---
 lisp/emacs-lisp/cl-seq.el            | 6 ++----
 test/lisp/emacs-lisp/cl-seq-tests.el | 8 ++++++++
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/lisp/emacs-lisp/cl-seq.el b/lisp/emacs-lisp/cl-seq.el
index 3eb6ea16da..86a73e1997 100644
--- a/lisp/emacs-lisp/cl-seq.el
+++ b/lisp/emacs-lisp/cl-seq.el
@@ -703,9 +703,7 @@ cl-member
 	(while (and cl-list (not (cl--check-test cl-item (car cl-list))))
 	  (setq cl-list (cdr cl-list)))
 	cl-list)
-    (if (and (numberp cl-item) (not (integerp cl-item)))
-	(member cl-item cl-list)
-      (memq cl-item cl-list))))
+    (memql cl-item cl-list)))
 (autoload 'cl--compiler-macro-member "cl-macs")
 
 ;;;###autoload
@@ -744,7 +742,7 @@ cl-assoc
 			(not (cl--check-test cl-item (car (car cl-alist))))))
 	  (setq cl-alist (cdr cl-alist)))
 	(and cl-alist (car cl-alist)))
-    (if (and (numberp cl-item) (not (integerp cl-item)))
+    (if (numberp cl-item)
 	(assoc cl-item cl-alist)
       (assq cl-item cl-alist))))
 (autoload 'cl--compiler-macro-assoc "cl-macs")
diff --git a/test/lisp/emacs-lisp/cl-seq-tests.el b/test/lisp/emacs-lisp/cl-seq-tests.el
index 86288e99ca..6515eee9f2 100644
--- a/test/lisp/emacs-lisp/cl-seq-tests.el
+++ b/test/lisp/emacs-lisp/cl-seq-tests.el
@@ -302,6 +302,14 @@ cl-seq--with-side-effects
     (should (equal '(2 8) (last (cl-replace list list2) 2)))
     (should (equal '(1 1) (last (cl-fill list 1) 2)))))
 
+(ert-deftest cl-seq-bignum-eql ()
+  (let ((x (+ most-positive-fixnum 1))
+        (y (+ most-positive-fixnum 1)))
+    (let ((l (list y)))
+      (should (eq (cl-member x l) l)))
+    (let ((a (list (cons y 1) (cons 2 y))))
+      (should (eq (cl-assoc x a) (car a)))
+      (should (eq (cl-rassoc x a) (cadr a))))))
 
 (provide 'cl-seq-tests)
 ;;; cl-seq-tests.el ends here
-- 
2.20.1 (Apple Git-117)


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-06-02 13:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-23 16:01 bug#35869: [PATCH] `cl-member' and `cl-assoc' do not work for bignums Mattias Engdegård
2019-06-02  1:15 ` Paul Eggert
2019-06-02 13:05   ` Mattias Engdegård

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.