* bug#33731: Fwd: 26.1; cl-make-random-state copying not working
[not found] <69b9732f-97f5-d752-c899-3bdc21cd74e8@cs.ucla.edu>
@ 2018-12-19 22:27 ` Paul Eggert
0 siblings, 0 replies; only message in thread
From: Paul Eggert @ 2018-12-19 22:27 UTC (permalink / raw)
To: 33731-done
[-- Attachment #1: Type: text/plain, Size: 162 bytes --]
Thanks for reporting this bug; it is a regression introduced when we
separated records from vectors. I installed the attached patch into the
emacs-26 branch.
[-- Attachment #2: 0001-cl-make-random-state-was-not-copying-its-arg.patch --]
[-- Type: text/x-patch, Size: 1712 bytes --]
From 78c883cc1c30ab82732eac02fb07bb747436854a Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Wed, 19 Dec 2018 13:42:21 -0800
Subject: [PATCH] cl-make-random-state was not copying its arg
Problem reported by Xu Chunyang (Bug#33731).
* lisp/emacs-lisp/cl-extra.el (cl-make-random-state):
Use copy-sequence, not copy-tree, so that the record is copied.
* test/lisp/emacs-lisp/cl-extra-tests.el:
(cl-extra-test-cl-make-random-state): New test.
---
| 2 +-
| 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
--git a/lisp/emacs-lisp/cl-extra.el b/lisp/emacs-lisp/cl-extra.el
index 36b65f97b0..c38b4957fc 100644
--- a/lisp/emacs-lisp/cl-extra.el
+++ b/lisp/emacs-lisp/cl-extra.el
@@ -484,7 +484,7 @@ cl-make-random-state
If STATE is t, return a new state object seeded from the time of day."
(unless state (setq state cl--random-state))
(if (cl-random-state-p state)
- (copy-tree state t)
+ (copy-sequence state)
(cl--make-random-state (if (integerp state) state (cl--random-time)))))
;; Implementation limits.
--git a/test/lisp/emacs-lisp/cl-extra-tests.el b/test/lisp/emacs-lisp/cl-extra-tests.el
index baad8eb8e6..fe59703530 100644
--- a/test/lisp/emacs-lisp/cl-extra-tests.el
+++ b/test/lisp/emacs-lisp/cl-extra-tests.el
@@ -94,4 +94,9 @@
(should (equal (list lst3 (cdr lst3) (cddr lst3))
(cl-maplist fn3 lst lst2 lst3)))))
+(ert-deftest cl-extra-test-cl-make-random-state ()
+ (let ((s (cl-make-random-state)))
+ ;; Test for Bug#33731.
+ (should-not (eq s (cl-make-random-state s)))))
+
;;; cl-extra-tests.el ends here
--
2.19.2
^ permalink raw reply related [flat|nested] only message in thread