unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#40180: 27.0.90; cl-concatenate returns wrong result
@ 2020-03-22  9:01 Joost Kremers
  2020-03-22 11:07 ` Stephen Berman
  0 siblings, 1 reply; 6+ messages in thread
From: Joost Kremers @ 2020-03-22  9:01 UTC (permalink / raw)
  To: 40180


`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. :-)



In GNU Emacs 27.0.90 (build 2, x86_64-pc-linux-gnu, GTK+ Version 
3.22.30)
 of 2020-03-11 built on IdeaPad
Repository revision: 1bc3fa0bd02cb167ae82b65fc56f95651d2bea16
Repository branch: emacs-27
Windowing system distributor 'The X.Org Foundation', version 
11.0.11906000
System Description: elementary OS 5.1.2 Hera

Recent messages:
Mark set
Auto-saving...
Mark set
Saving file 
/home/joost/Mail/Fastmail/Drafts/cur/1584867450.a5b0e4c5936e9702.ideapad:2,DS...
Wrote 
/home/joost/Mail/Fastmail/Drafts/cur/1584867450.a5b0e4c5936e9702.ideapad:2,DS
[mu4e] Saved (30 lines)
Detected language: English
Saving file 
/home/joost/Mail/Fastmail/Drafts/cur/1584867450.a5b0e4c5936e9702.ideapad:2,DS...
Wrote 
/home/joost/Mail/Fastmail/Drafts/cur/1584867450.a5b0e4c5936e9702.ideapad:2,DS
[mu4e] Saved (31 lines)

Configured features:
XPM JPEG TIFF GIF PNG RSVG SOUND DBUS GSETTINGS GLIB NOTIFY 
INOTIFY GNUTLS
LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF XFT ZLIB 
TOOLKIT_SCROLL_BARS GTK3 X11
XDBE XIM MODULES THREADS PDUMPER LCMS2 GMP
Important settings:
  value of $LC_MONETARY: en_IE.UTF-8
  value of $LC_NUMERIC: en_IE.UTF-8
  value of $LC_TIME: en_IE.UTF-8
  value of $LANG: en_GB.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: IELM

Minor modes in effect:
  global-magit-file-mode: t
  magit-auto-revert-mode: t
  global-git-commit-mode: t
  async-bytecomp-package-mode: t
  shell-dirtrack-mode: t
  flycheck-indicator-mode: t
  company-box-mode: t
  minions-mode: t
  doom-modeline-mode: t
  which-key-mode: t
  global-undo-tree-mode: t
  undo-tree-mode: t
  global-atomic-chrome-edit-mode: t
  ivy-mode: t
  recentf-mode: t
  pyvenv-mode: t
  projectile-mode: t
  global-diff-hl-mode: t
  electric-pair-mode: t
  TeX-PDF-mode: t
  TeX-source-correlate-mode: t
  company-quickhelp-mode: t
  company-quickhelp-local-mode: t
  global-company-mode: t
  company-mode: t
  show-paren-mode: t
  delete-selection-mode: t
  override-global-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t
  auto-save-visited-mode: t

Load-path shadows:
~/.emacs.d/lisp/custom hides 
/usr/local/share/emacs/27.0.90/lisp/custom

Features:
(shadow emacsbug mail-extr forge-list forge-commands forge-semi 
forge-bitbucket
buck forge-gogs gogs forge-gitea gtea forge-gitlab glab 
forge-github
ghub-graphql treepy gsexp ghub forge-notify forge-revnote 
forge-pullreq
forge-issue forge-topic bug-reference forge-post forge-repo forge 
forge-core
forge-db closql emacsql-sqlite emacsql emacsql-compiler url-http 
url-auth url-gw
magit-bookmark magit-submodule magit-obsolete magit-blame 
magit-stash
magit-reflog magit-bisect magit-push magit-pull magit-fetch 
magit-clone
magit-remote magit-commit magit-sequence magit-notes 
magit-worktree magit-tag
magit-merge magit-branch magit-reset magit-files magit-refs 
magit-status magit
magit-repos magit-apply magit-wip magit-log which-func magit-diff 
smerge-mode
magit-core magit-autorevert magit-margin magit-transient 
magit-process
magit-mode git-commit magit-git magit-section magit-utils log-edit 
pcvs-util
add-log with-editor async-bytecomp async org-mu4e gnus-dired mu4e 
desktop
frameset mu4e-org org-clock org org-macro org-footnote 
org-pcomplete org-list
org-faces org-entities org-version ob-scheme ob-clojure ob-python 
ob ob-tangle
org-src ob-ref ob-lob ob-table ob-exp ob-comint ob-emacs-lisp 
ob-core ob-eval ol
org-loaddefs mu4e-main mu4e-view cal-menu calendar cal-loaddefs 
mu4e-headers
mu4e-compose mu4e-context mu4e-draft mu4e-actions ido rfc2368 
smtpmail sendmail
mu4e-mark mu4e-message flow-fill mu4e-proc mu4e-utils doc-view 
jka-compr
image-mode exif mu4e-lists mu4e-vars message rfc822 mml mml-sec 
epa derived epg
epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies 
mm-encode
mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr 
mailabbrev
mail-utils gmm-utils mailheader mu4e-meta visual-fill-column 
mixed-pitch
cl-print view lsp-yaml lsp-xml lsp-vhdl lsp-vetur lsp-html 
lsp-verilog
lsp-terraform lsp-solargraph lsp-rust lsp-python-ms lsp-pyls 
lsp-pwsh lsp-perl
lsp-metals lsp-json url url-proxy url-privacy url-expand 
url-methods url-history
mailcap lsp-intelephense lsp-haxe lsp-go lsp-gdscript lsp-fsharp 
lsp-eslint
lsp-erlang lsp-elm lsp-dls lsp-dart lsp-css lsp-csharp gnutls 
lsp-clojure
lsp-clients py-autopep8 python-pytest magit-popup python tramp-sh 
tramp
tramp-loaddefs trampver tramp-integration files-x tramp-compat 
shell parse-time
iso8601 time-date ls-lisp mule-util multiple-cursors-core rect 
pcmpl-unix edebug
backtrace vc-git bookmark text-property-search face-remap el-spice 
list-callers
flycheck-indicator hl-line jk-input-methods quail em-unix em-term 
term
disp-table ehelp em-script em-prompt em-ls em-hist em-pred em-dirs 
esh-var
em-cmpl pcomplete em-basic em-banner em-alias esh-mode company-box
company-box-doc company-box-icons ielm pp minions doom-modeline
doom-modeline-segments doom-modeline-env doom-modeline-core 
shrink-path
which-key undo-tree diff solarized-light-theme solarized-theme 
solarized
solarized-faces atomic-chrome websocket url-cookie url-domsuf 
iimage image+
image-file swiper ivy-hydra all-the-icons-ivy ivy colir 
ivy-overlay recentf
poetry pyvenv transient paredit clojure-mode lisp-mnt align 
eldoc-box
company-lsp lsp-ui lsp-ui-flycheck lsp-ui-doc goto-addr 
lsp-ui-imenu lsp-ui-peek
lsp-ui-sideline flycheck-posframe posframe flycheck lsp-mode 
url-util
tree-widget network-stream puny nsm rmc markdown-mode rx color 
noutline outline
inline imenu ht f em-glob dash-functional bindat ag vc-svn 
find-dired s
projectile grep ibuf-ext ibuffer ibuffer-loaddefs diff-hl vc-dir 
ewoc vc
vc-dispatcher diff-mode autorevert filenotify aggressive-indent 
elec-pair
nswbuff guess-language flyspell ispell find-func ace-window avy 
dired
dired-loaddefs reftex reftex-loaddefs reftex-vars company-auctex 
yasnippet latex
latex-flymake flymake-proc flymake compile comint ansi-color 
warnings thingatpt
tex-ispell tex-style tex crm company-quickhelp pos-tip 
all-the-icons
all-the-icons-faces data-material data-weathericons data-octicons 
data-fileicons
data-faicons data-alltheicons memoize company-oddmuse 
company-keywords
company-etags etags fileloop generator xref project company-gtags
company-dabbrev-code company-dabbrev company-files company-capf 
company-cmake
company-xcode company-clang company-semantic company-template 
company-css
company-bbdb company tab-jump-out adaptive-wrap bm paradox 
paradox-menu
paradox-commit-list hydra ring lv cus-edit wid-edit 
paradox-execute
paradox-github paradox-core spinner cl-extra help-mode 
jk-functions let-alist
org-table org-keys org-compat org-macs format-spec pcase advice 
eshell esh-cmd
esh-ext esh-opt esh-proc esh-io esh-arg esh-module esh-groups 
esh-util
notifications dbus xml dash edmacro kmacro server paren delsel 
cus-start
cus-load use-package use-package-ensure use-package-delight 
use-package-diminish
use-package-bind-key bind-key easy-mmode use-package-core 
finder-inf tex-site
info package easymenu browse-url url-handlers url-parse 
auth-source cl-seq eieio
eieio-core cl-macs eieio-loaddefs password-cache json subr-x map 
url-vars seq
byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib tooltip 
eldoc
electric uniquify ediff-hook vc-hooks lisp-float-type mwheel 
term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode 
prog-mode
register page tab-bar menu-bar rfn-eshadow isearch timer select 
scroll-bar mouse
jit-lock font-lock syntax facemenu font-core term/tty-colors frame 
minibuffer
cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan 
thai tai-viet
lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak 
czech european
ethiopic indian cyrillic chinese composite charscript charprop 
case-table
epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded 
nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 
md5 base64
format env code-pages mule custom widget hashtable-print-readable 
backquote
threads dbusbind inotify lcms2 dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty 
make-network-process
emacs)

Memory information:
((conses 16 667592 42193)
 (symbols 48 51699 1)
 (strings 32 212155 6674)
 (string-bytes 1 6356856)
 (vectors 16 84841)
 (vector-slots 8 1171666 58618)
 (floats 8 1100 424)
 (intervals 56 3076 1774)
 (buffers 1000 36))

-- 
Joost Kremers
Life has its moments





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#40180: 27.0.90; cl-concatenate returns wrong result
  2020-03-22  9:01 bug#40180: 27.0.90; cl-concatenate returns wrong result Joost Kremers
@ 2020-03-22 11:07 ` Stephen Berman
  2020-03-22 11:53   ` Noam Postavsky
  0 siblings, 1 reply; 6+ messages in thread
From: Stephen Berman @ 2020-03-22 11:07 UTC (permalink / raw)
  To: Joost Kremers; +Cc: 40180

[-- 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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* bug#40180: 27.0.90; cl-concatenate returns wrong result
  2020-03-22 11:07 ` Stephen Berman
@ 2020-03-22 11:53   ` Noam Postavsky
  2020-03-22 12:00     ` Stephen Berman
  2020-03-22 13:57     ` Eli Zaretskii
  0 siblings, 2 replies; 6+ messages in thread
From: Noam Postavsky @ 2020-03-22 11:53 UTC (permalink / raw)
  To: Stephen Berman; +Cc: Joost Kremers, 40180

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

tags 40180 + patch
quit

Stephen Berman <stephen.berman@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.


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

From 97642d1265984c4a22023dc3ff6e8142a325598b Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* bug#40180: 27.0.90; cl-concatenate returns wrong result
  2020-03-22 11:53   ` Noam Postavsky
@ 2020-03-22 12:00     ` Stephen Berman
  2020-03-22 13:57     ` Eli Zaretskii
  1 sibling, 0 replies; 6+ messages in thread
From: Stephen Berman @ 2020-03-22 12:00 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: Joost Kremers, 40180

On Sun, 22 Mar 2020 07:53:31 -0400 Noam Postavsky <npostavs@gmail.com> wrote:

> tags 40180 + patch
> quit
>
> Stephen Berman <stephen.berman@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.

Oh, yes, of course.

Steve Berman





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#40180: 27.0.90; cl-concatenate returns wrong result
  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
  1 sibling, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2020-03-22 13:57 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: joostkremers, 40180, stephen.berman

> From: Noam Postavsky <npostavs@gmail.com>
> Date: Sun, 22 Mar 2020 07:53:31 -0400
> Cc: Joost Kremers <joostkremers@fastmail.fm>, 40180@debbugs.gnu.org
> 
> Stephen Berman <stephen.berman@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.

Thanks, please push this to the emacs-27 branch.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#40180: 27.0.90; cl-concatenate returns wrong result
  2020-03-22 13:57     ` Eli Zaretskii
@ 2020-03-23  3:14       ` Noam Postavsky
  0 siblings, 0 replies; 6+ messages in thread
From: Noam Postavsky @ 2020-03-23  3:14 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: joostkremers, 40180, stephen.berman

tags 40180 fixed
close 40180 27.1
quit

Eli Zaretskii <eliz@gnu.org> writes:

> Thanks, please push this to the emacs-27 branch.

Done.

[1: 9ab85f087f]: 2020-03-22 23:06:31 -0400
  Fix cl-concatenate (Bug#40180)
  https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=9ab85f087f7db38168dcf07d24f51ecd2c583f8a





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-03-23  3:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-22  9:01 bug#40180: 27.0.90; cl-concatenate returns wrong result Joost Kremers
2020-03-22 11:07 ` Stephen Berman
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

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).