Subject: bug#50781: 27.2; completing-read with a vector

From: Al Haji-Ali <[email-masked]>
Date: Fri, 24 Sep 2021 14:49:51 +0100

I am not sure if `completing-read` is supposed to accept a vector but an error is not thrown on this usage (incidentally helpful uses `completing-read` in this way).

However, starting from `emacs -Q` and executing the following code

(completing-read "Test: " [A B C])

works but then pressing <TAB> for auto-completion shows objects beside A, B and C.

On the other hand, executing
(completing-read "Test: " [1 2 3])
and then pressing <TAB> shows the error `(error "Bad data in guts of obarray")`

with the following call stack

,----
| Debugger entered--Lisp error: (error "Bad data in guts of obarray")
|   try-completion("" [1 2 3] nil)
|   completion-basic-try-completion("" [1 2 3] nil 0)
|   #f(compiled-function (style) #<bytecode 0x7d5815>)(basic)
|   completion--some(#f(compiled-function (style) #<bytecode 0x7d5815>) (basic partial-completion emacs22))
|   completion--nth-completion(1 "" [1 2 3] nil 0 (metadata))
|   completion-try-completion("" [1 2 3] nil 0 (metadata))
|   completion--do-completion(7 7)
|   completion--in-region-1(7 7)
|   #f(compiled-function (start end collection predicate) #<bytecode 0x1ff60569ee1d>)(7 7 [1 2 3] nil)
|   apply(#f(compiled-function (start end collection predicate) #<bytecode 0x1ff60569ee1d>) (7 7 [1 2 3] nil))
|   #f(compiled-function (funs global args) #<bytecode 0x7d57ed>)(nil nil (7 7 [1 2 3] nil))
|   completion--in-region(7 7 [1 2 3] nil)
|   completion-in-region(7 7 [1 2 3] nil)
|   minibuffer-complete()
|   funcall-interactively(minibuffer-complete)
|   call-interactively(minibuffer-complete nil nil)
|   command-execute(minibuffer-complete)
|   read-from-minibuffer("Test: " nil (keymap (menu-bar keymap (minibuf "Minibuf" keymap (tab menu-item "Complete" minibuffer-complete :help "Complete as far as possible") (space menu-item "Complete Word" minibuffer-complete-word :help "Complete at most one word") (63 menu-item "List Completions" minibuffer-completion-help :help "Display all possible completions") "Minibuf")) (27 keymap (118 . switch-to-completions)) (prior . switch-to-completions) (63 . minibuffer-completion-help) (32 . minibuffer-complete-word) (9 . minibuffer-complete) keymap (menu-bar keymap (minibuf "Minibuf" keymap (previous menu-item "Previous History Item" previous-history-element :help "Put previous minibuffer history element in the min...") (next menu-item "Next History Item" next-history-element :help "Put next minibuffer history element in the minibuf...") (isearch-backward menu-item "Isearch History Backward" isearch-backward :help "Incrementally search minibuffer history backward") (isearch-forward menu-item "Isearch History Forward" isearch-forward :help "Incrementally search minibuffer history forward") (return menu-item "Enter" exit-minibuffer :key-sequence "\15" :help "Terminate input and exit minibuffer") (quit menu-item "Quit" abort-recursive-edit :help "Abort input and exit minibuffer") "Minibuf")) (10 . exit-minibuffer) (13 . exit-minibuffer) (7 . abort-recursive-edit) (C-tab . file-cache-minibuffer-complete) (9 . self-insert-command) (XF86Back . previous-history-element) (up . previous-line-or-history-element) (prior . previous-history-element) (XF86Forward . next-history-element) (down . next-line-or-history-element) (next . next-history-element) (27 keymap (60 . minibuffer-beginning-of-buffer) (114 . previous-matching-history-element) (115 . next-matching-history-element) (112 . previous-history-element) (110 . next-history-element))) nil nil nil nil)
|   completing-read-default("Test: " [1 2 3] nil nil nil nil nil nil)
|   completing-read("Test: " [1 2 3])
|   (progn (completing-read "Test: " [1 2 3]))
|   eval((progn (completing-read "Test: " [1 2 3])) t)
|   elisp--eval-last-sexp(nil)
|   eval-last-sexp(nil)
|   funcall-interactively(eval-last-sexp nil)
|   call-interactively(eval-last-sexp nil nil)
|   command-execute(eval-last-sexp)
`----

In GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30, cairo version 1.15.12)
 of 2021-05-18 built on lxstaff02
Repository revision: deef5efafb70f4b171265b896505b92b6eef24e6
Repository branch: HEAD
Windowing system distributor 'The X.Org Foundation', version 11.0.12004000
System Description: CentOS Linux 7 (Core)

Configured using:
 'configure --prefix=$HOME/.local/ --with-json --with-modules
 --with-harfbuzz --with-compress-install --with-threads
 --with-included-regex --with-zlib --with-sound=alsa --without-gconf
 --with-mailutils --with-xft --with-xml2 --with-cairo --with-gconf
 --with-xwidgets --without-toolkit-scroll-bars 'CFLAGS=-O3 -mtune=native
 -march=native -fomit-frame-pointer
 -I/usr/lib/gcc/x86_64-linux-gnu/9/include/
 -L/usr/lib/gcc/x86_64-linux-gnu/9'
 PKG_CONFIG_PATH=$HOME/.local/lib/pkgconfig:/usr/lib64/pkgconfig/:/usr/share/pkgconfig/
 CPPFLAGS=-I$HOME/.local/include LDFLAGS=-L$HOME/.local/lib'

Configured features:
XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND DBUS GSETTINGS GLIB NOTIFY
INOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE HARFBUZZ ZLIB GTK3 X11
XDBE XIM MODULES THREADS XWIDGETS PDUMPER GMP

Important settings:
  value of $LANG: en_GB.utf8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-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
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
format-spec rfc822 mml mml-sec password-cache epa derived epg epg-config
gnus-util rmail rmail-loaddefs text-property-search time-date subr-x seq
byte-opt gv bytecomp byte-compile cconv mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047
rfc2045 ietf-drums mm-util mail-prsvr mail-utils help-fns radix-tree
cl-print debug backtrace help-mode easymenu find-func 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 dynamic-setting system-font-setting font-render-setting
xwidget-internal cairo move-toolbar gtk x-toolkit x multi-tty
make-network-process emacs)

Memory information:
((conses 16 52982 7459)
 (symbols 48 6420 1)
 (strings 32 17020 2200)
 (string-bytes 1 561499)
 (vectors 16 10092)
 (vector-slots 8 133817 11898)
 (floats 8 22 43)
 (intervals 56 705 1)
 (buffers 1000 13)
 (heap 1024 11972 1101))