Subject: bug#56203: 28.1; completing-read-multiple fails from inside the completion table

From: Harald Judt <[email-masked]>
Date: Fri, 24 Jun 2022 19:12:30 +0200

Hi,

I have posted my initial bug report here, because I first thought this
was a bug in the package vertico though it isn't:
https://github.com/minad/vertico/issues/244

The author of this package says this is an emacs bug, I am going to
quote him here because he gives more examples and in-depth explanation
than I have provided:

---
Thanks! I can confirm this on Emacs 28.1. This is an upstream bug. Please 
report it upstream via report-emacs-bug (maybe cc Stefan Monnier who is the 
expert on the table quotation mechanism).

     1. I argue that Vertico calls the API completion-all-completions in the 
correct way.
     2. Icomplete use the API completion-all-completions in the same way and 
fails too.
     3. Default completion fails too if you enter ~, M-x minibuffer-complete 
RET. Note that completing-read-multiple overrides minibuffer-complete with 
crm-complete which shadows the underlying bug in the completion table.
     4. The error occurs from inside the completion table, and not from 
Vertico code.
---

Here is the elisp debugger backtrace for my example:
Debugger entered--Lisp error: (args-out-of-range "" 0 6)
   completion--file-name-table("" 6 completion--unquote)
   complete-with-action(completion--unquote completion--file-name-table "" 6)
   #f(compiled-function (table) #<bytecode 
0x17ceea27424a904e>)(completion--file-name-table)
   completion--some(#f(compiled-function (table) #<bytecode 
0x17ceea27424a904e>) (completion--embedded-envvar-table 
completion--file-name-table))
   read-file-name-internal("" 6 completion--unquote)
   complete-with-action(completion--unquote read-file-name-internal "" 6)
   completion-table-with-context(#("~/tmp," 0 6 (face nil)) 
read-file-name-internal "" 6 completion--unquote)
   crm--collection-fn(#("~/tmp," 0 6 (face nil)) 6 completion--unquote)
   completion--nth-completion(2 #("~/tmp," 0 6 (face nil)) crm--collection-fn 
file-directory-p 6 (metadata (category . file) (completion--unquote-requote . t)))
   #<subr completion-all-completions>(#("~/tmp," 0 6 (face nil)) 
crm--collection-fn file-directory-p 6 (metadata (category . file) 
(completion--unquote-requote . t)))
   apply(#<subr completion-all-completions> (#("~/tmp," 0 6 (face nil)) 
crm--collection-fn file-directory-p 6 (metadata (category . file) 
(completion--unquote-requote . t))))
   completion-all-completions(#("~/tmp," 0 6 (face nil)) crm--collection-fn 
file-directory-p 6 (metadata (category . file) (completion--unquote-requote . t)))
   vertico--all-completions(#("~/tmp," 0 6 (face nil)) crm--collection-fn 
file-directory-p 6 (metadata (category . file) (completion--unquote-requote . t)))
   vertico--recompute-candidates(6 #("~/tmp," 0 6 (face nil)))
   vertico--update-candidates(6 #("~/tmp," 0 6 (face nil)))
   vertico--exhibit()
   #<subr completing-read-multiple>("Directories: " read-file-name-internal 
file-directory-p t nil nil "~/")
   vertico-multiform--advice(#<subr completing-read-multiple> "Directories: " 
read-file-name-internal file-directory-p t nil nil "~/")
   apply(vertico-multiform--advice (#<subr completing-read-multiple> 
"Directories: " read-file-name-internal file-directory-p t nil nil "~/"))
   vertico--advice(#<subr completing-read-multiple> "Directories: " 
read-file-name-internal file-directory-p t nil nil "~/")
   apply(vertico--advice #<subr completing-read-multiple> ("Directories: " 
read-file-name-internal file-directory-p t nil nil "~/"))
   completing-read-multiple("Directories: " read-file-name-internal 
file-directory-p t nil nil "~/")
   elisp--eval-last-sexp(nil)
   eval-last-sexp(nil)
   funcall-interactively(eval-last-sexp nil)
   command-execute(eval-last-sexp)

In GNU Emacs 28.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.34, cairo 
version 1.16.0)
  of 2022-06-01 built on localhost
Windowing system distributor 'The X.Org Foundation', version 11.0.12101003
System Description: Gentoo Linux

Configured using:
  'configure --prefix=/usr --build=x86_64-pc-linux-gnu
  --host=x86_64-pc-linux-gnu --mandir=/usr/share/man
  --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc
  --localstatedir=/var/lib --datarootdir=/usr/share
  --disable-silent-rules --docdir=/usr/share/doc/emacs-28.1
  --htmldir=/usr/share/doc/emacs-28.1/html --libdir=/usr/lib64
  --program-suffix=-emacs-28 --includedir=/usr/include/emacs-28
  --infodir=/usr/share/info/emacs-28 --localstatedir=/var
  --enable-locallisppath=/etc/emacs:/usr/share/emacs/site-lisp
  --without-compress-install --without-hesiod --without-pop
  --with-file-notification=inotify --with-pdumper --disable-acl
  --with-dbus --with-modules --with-gameuser=:gamestat --with-libgmp
  --without-gpm --with-native-compilation --with-json --without-kerberos
  --without-kerberos5 --with-lcms2 --with-xml2 --without-mailutils
  --without-selinux --with-gnutls --without-libsystemd --with-threads
  --without-wide-int --with-zlib --with-sound=alsa --with-x --without-ns
  --without-gconf --without-gsettings --with-toolkit-scroll-bars
  --with-gif --with-jpeg --with-png --with-rsvg --with-tiff --with-xpm
  --with-imagemagick --with-xft --with-cairo --with-harfbuzz
  --without-libotf --without-m17n-flt --with-x-toolkit=gtk3
  --without-xwidgets --with-dumping=pdumper 'CFLAGS=-march=native -O2
  -pipe -fno-ident -ggdb' CPPFLAGS= 'LDFLAGS=-Wl,-O1 -Wl,--as-needed
  -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,--sort-common
  -Wl,-z,now''

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS HARFBUZZ IMAGEMAGICK JPEG JSON
LCMS2 LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG
SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM GTK3
ZLIB

Important settings:
   value of $LC_ALL: de_DE.UTF-8
   value of $LANG: de_DE.UTF-8
   locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
   tooltip-mode: t
   global-eldoc-mode: t
   eldoc-mode: t
   show-paren-mode: t
   electric-indent-mode: t
   mouse-wheel-mode: t
   tool-bar-mode: t
   menu-bar-mode: t
   file-name-shadow-mode: t
   global-font-lock-mode: t
   font-lock-mode: t
   blink-cursor-mode: t
   auto-composition-mode: t
   auto-encryption-mode: t
   auto-compression-mode: t
   line-number-mode: t
   indent-tabs-mode: t
   transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg rfc6068 epg-config gnus-util rmail
rmail-loaddefs auth-source eieio eieio-core eieio-loaddefs
password-cache json map text-property-search time-date mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils comp
comp-cstr warnings subr-x rx cl-seq cl-macs cl-extra help-mode seq
byte-opt gv cl-loaddefs cl-lib bytecomp byte-compile cconv iso-transl
tooltip eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode 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 lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock
font-lock syntax 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 emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice button loaddefs faces cus-face macroexp files
window text-properties overlay sha1 md5 base64 format env code-pages
mule custom widget hashtable-print-readable backquote threads dbusbind
inotify lcms2 dynamic-setting font-render-setting cairo move-toolbar gtk
x-toolkit x multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 77319 8541)
  (symbols 48 7849 1)
  (strings 32 22068 4871)
  (string-bytes 1 760949)
  (vectors 16 17362)
  (vector-slots 8 309931 16542)
  (floats 8 26 27)
  (intervals 56 286 0)
  (buffers 992 11))

Kind regards,
Harald Judt

-- 
`Experience is the best teacher.'

PGP Key ID: 4FFFAB21B8580ABD
Fingerprint: E073 6DD8 FF40 9CF2 0665 11D4 4FFF AB21 B858 0ABD