Commit f4ea7464 authored by Paul Eggert's avatar Paul Eggert

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.
parent fda43a7b
Pipeline #334 failed with stage
in 4 seconds
......@@ -484,7 +484,7 @@ Optional second arg STATE is a random-state object."
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.
......
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment