all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stephen Berman <stephen.berman@gmx.net>
To: Joost Kremers <joostkremers@fastmail.fm>
Cc: 40180@debbugs.gnu.org
Subject: bug#40180: 27.0.90; cl-concatenate returns wrong result
Date: Sun, 22 Mar 2020 12:07:29 +0100	[thread overview]
Message-ID: <871rpksl5a.fsf@gmx.net> (raw)
In-Reply-To: <878sjs69w1.fsf@fastmail.fm> (Joost Kremers's message of "Sun, 22 Mar 2020 10:01:34 +0100")

[-- Attachment #1: Type: text/plain, Size: 815 bytes --]

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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: seq-concatenate patch --]
[-- Type: text/x-patch, Size: 861 bytes --]

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.

[-- Attachment #3: Type: text/plain, Size: 108 bytes --]


Maybe cl-defgeneric should be fixed instead, but I don't understand it
well enough to do so.

Steve Berman

  reply	other threads:[~2020-03-22 11:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-22  9:01 bug#40180: 27.0.90; cl-concatenate returns wrong result Joost Kremers
2020-03-22 11:07 ` Stephen Berman [this message]
2020-03-22 11:53   ` Noam Postavsky
2020-03-22 12:00     ` Stephen Berman
2020-03-22 13:57     ` Eli Zaretskii
2020-03-23  3:14       ` Noam Postavsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871rpksl5a.fsf@gmx.net \
    --to=stephen.berman@gmx.net \
    --cc=40180@debbugs.gnu.org \
    --cc=joostkremers@fastmail.fm \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.