GNU bug report logs - #50781
27.2; completing-read with a vector

Previous Next

Package: emacs;

Reported by: Al Haji-Ali <abdo.haji.ali <at> gmail.com>

Date: Fri, 24 Sep 2021 14:04:01 UTC

Severity: normal

Tags: notabug

Found in version 27.2

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 50781 in the body.
You can then email your comments to 50781 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#50781; Package emacs. (Fri, 24 Sep 2021 14:04:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Al Haji-Ali <abdo.haji.ali <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 24 Sep 2021 14:04:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Al Haji-Ali <abdo.haji.ali <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.2; completing-read with a vector
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))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50781; Package emacs. (Sat, 25 Sep 2021 02:16:01 GMT) Full text and rfc822 format available.

Message #8 received at 50781 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Al Haji-Ali <abdo.haji.ali <at> gmail.com>
Cc: 50781 <at> debbugs.gnu.org
Subject: Re: bug#50781: 27.2; completing-read with a vector
Date: Sat, 25 Sep 2021 04:15:12 +0200
Al Haji-Ali <abdo.haji.ali <at> gmail.com> writes:

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

The documentation here says:

COLLECTION can be a list of strings, an alist, an obarray or a hash table.

So using a vector isn't really supported, but works in some instances by
chance.

> 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")`

It interprets all vectors as obarrays, and an obarray is just a vector
of symbols.  But numbers aren't symbols, which is what it's complaining
about.

We could make `completing-read' iterate over all the elements in the
vector to see whether it's valid, and signal an error earlier, but it
would make common usages slower.

So I don't think there's an error in Emacs here -- feeding a
(non-obarray) vector to `completing-read' is not supported, and is an
error in the code that does it.  So I'm closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) notabug. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 25 Sep 2021 02:16:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 50781 <at> debbugs.gnu.org and Al Haji-Ali <abdo.haji.ali <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 25 Sep 2021 02:16:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 23 Oct 2021 11:24:10 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 185 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.