From 09a66ceb5e906e704be58d5f40c45096307f0b9e Mon Sep 17 00:00:00 2001 From: Nicolas Petton Date: Thu, 15 Dec 2016 10:24:57 +0100 Subject: [PATCH] Fix circular list handling in seq-mapn * lisp/emacs-lisp/seq.el (seq-mapn): Do not copy list arguments. * test/lisp/emacs-lisp/seq-tests.el (test-seq-mapn-circular-lists): Add a regression test. --- lisp/emacs-lisp/seq.el | 5 ++++- test/lisp/emacs-lisp/seq-tests.el | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el index 5ddc5a53a32..9890e60614e 100644 --- a/lisp/emacs-lisp/seq.el +++ b/lisp/emacs-lisp/seq.el @@ -178,7 +178,10 @@ Return a list of the results. \(fn FUNCTION SEQUENCES...)" (let ((result nil) - (sequences (seq-map (lambda (s) (seq-into s 'list)) + (sequences (seq-map (lambda (s) + (if (listp s) + s + (seq-into s 'list))) (cons sequence sequences)))) (while (not (memq nil sequences)) (push (apply function (seq-map #'car sequences)) result) diff --git a/test/lisp/emacs-lisp/seq-tests.el b/test/lisp/emacs-lisp/seq-tests.el index 2e533acce17..fc65c9834d6 100644 --- a/test/lisp/emacs-lisp/seq-tests.el +++ b/test/lisp/emacs-lisp/seq-tests.el @@ -386,5 +386,10 @@ Evaluate BODY for each created sequence. (should-error (seq-random-elt [])) (should-error (seq-random-elt ""))) +(ert-deftest test-seq-mapn-circular-lists () + (let ((l1 '#1=(1 . #1#))) + (should (equal (seq-mapn #'+ '(3 4 5 7) l1) + '(4 5 6 8))))) + (provide 'seq-tests) ;;; seq-tests.el ends here -- 2.39.2