[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#40180: 27.0.90; cl-concatenate returns wrong result
From: |
Stephen Berman |
Subject: |
bug#40180: 27.0.90; cl-concatenate returns wrong result |
Date: |
Sun, 22 Mar 2020 12:07:29 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
On Sun, 22 Mar 2020 10:01:34 +0100 Joost Kremers <joostkremers@fastmail.fm>
wrote:
> `cl-concatenate` seems to return the wrong result:
>
> ```
> ELISP> (cl-concatenate 'list '(a b c) '(d e f))
> ((a b c) (d e f))
> ```
>
> In Emacs 26 the return value was `(a b c d e f)`, which I assume should still
> be the return value in Emacs 27, given that Common Lisp hasn't changed. :-)
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. Hence, the following patch restores the correct
pre-27 behavior:
diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el
index e3037a7190..adfb63dba8 100644
--- a/lisp/emacs-lisp/seq.el
+++ b/lisp/emacs-lisp/seq.el
@@ -289,11 +289,12 @@ seq-concatenate
TYPE must be one of following symbols: vector, string or list.
\n(fn TYPE SEQUENCE...)"
- (pcase type
- ('vector (apply #'vconcat sequences))
- ('string (apply #'concat sequences))
- ('list (apply #'append (append sequences '(nil))))
- (_ (error "Not a sequence type name: %S" type))))
+ (let ((sequences (car sequences)))
+ (pcase type
+ ('vector (apply #'vconcat sequences))
+ ('string (apply #'concat sequences))
+ ('list (apply #'append (append sequences '(nil))))
+ (_ (error "Not a sequence type name: %S" type)))))
(cl-defgeneric seq-into-sequence (sequence)
"Convert SEQUENCE into a sequence.
Maybe cl-defgeneric should be fixed instead, but I don't understand it
well enough to do so.
Steve Berman