GNU bug report logs - #40180
27.0.90; cl-concatenate returns wrong result

Previous Next

Package: emacs;

Reported by: Joost Kremers <joostkremers <at> fastmail.fm>

Date: Sun, 22 Mar 2020 09:02:01 UTC

Severity: normal

Tags: fixed, patch

Found in version 27.0.90

Fixed in version 27.1

Done: Noam Postavsky <npostavs <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #11 received at 40180 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> gmail.com>
To: Stephen Berman <stephen.berman <at> gmx.net>
Cc: Joost Kremers <joostkremers <at> fastmail.fm>, 40180 <at> debbugs.gnu.org
Subject: Re: bug#40180: 27.0.90; cl-concatenate returns wrong result
Date: Sun, 22 Mar 2020 07:53:31 -0400
[Message part 1 (text/plain, inline)]
tags 40180 + patch
quit

Stephen Berman <stephen.berman <at> gmx.net> writes:

> Similarly, (cl-concatenate 'vector '[a b c] '[d e f]) returns `[[a b c]
> [d e f]]' and worse, (cl-concatenate 'string "abc" "def") raises the
> error: Wrong type argument: characterp, "abc".  This is because
> cl-concatenate is now defined in terms of seq-concatenate, which is
> defined by cl-defgeneric, which adds an extra pair of parens around the
> SEQUENCES argument

I think the problem is just that cl-concatenate should call
seq-concatenate with apply.

[0001-Fix-cl-concatenate-Bug-40180.patch (text/x-diff, inline)]
From 97642d1265984c4a22023dc3ff6e8142a325598b Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Sun, 22 Mar 2020 07:48:14 -0400
Subject: [PATCH] Fix cl-concatenate (Bug#40180)

* lisp/emacs-lisp/cl-extra.el (cl-concatenate): Use apply, to avoid
adding extra nesting of args.
* test/lisp/emacs-lisp/cl-extra-tests.el (cl-concatenate): New test.
---
 lisp/emacs-lisp/cl-extra.el            | 2 +-
 test/lisp/emacs-lisp/cl-extra-tests.el | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/cl-extra.el b/lisp/emacs-lisp/cl-extra.el
index e9bfe8df5f..ce6fb625bc 100644
--- a/lisp/emacs-lisp/cl-extra.el
+++ b/lisp/emacs-lisp/cl-extra.el
@@ -556,7 +556,7 @@ cl-subseq
 (defun cl-concatenate (type &rest sequences)
   "Concatenate, into a sequence of type TYPE, the argument SEQUENCEs.
 \n(fn TYPE SEQUENCE...)"
-  (seq-concatenate type sequences))
+  (apply #'seq-concatenate type sequences))
 
 ;;; List functions.
 
diff --git a/test/lisp/emacs-lisp/cl-extra-tests.el b/test/lisp/emacs-lisp/cl-extra-tests.el
index 2d20ba75d2..7546c14937 100644
--- a/test/lisp/emacs-lisp/cl-extra-tests.el
+++ b/test/lisp/emacs-lisp/cl-extra-tests.el
@@ -99,4 +99,12 @@ cl-extra-test-cl-make-random-state
     ;; Test for Bug#33731.
     (should-not (eq s (cl-make-random-state s)))))
 
+(ert-deftest cl-concatenate ()
+  (should (equal (cl-concatenate 'list '(1 2 3) '(4 5 6))
+                 '(1 2 3 4 5 6)))
+  (should (equal (cl-concatenate 'vector [1 2 3] [4 5 6])
+                 [1 2 3 4 5 6]))
+  (should (equal (cl-concatenate 'string "123" "456")
+                 "123456")))
+
 ;;; cl-extra-tests.el ends here
-- 
2.11.0


This bug report was last modified 5 years and 63 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.