minad / vertico

:dizzy: vertico.el - VERTical Interactive COmpletion
GNU General Public License v3.0
1.48k stars 60 forks source link

Error in post-command-hook (vertico--exhibit): (wrong-type-argument listp 0) #358

Closed smaximov closed 1 year ago

smaximov commented 1 year ago

Hello! With the following minimal config:

(require 'vertico)
(vertico-mode)

(setq debug-on-error t)

(defun force-debug (func &rest args)
  (condition-case e
      (apply func args)
    ((debug error) (signal (car e) (cdr e)))))

(advice-add #'vertico--exhibit :around #'force-debug)

when I run M-x, I get "Error in post-command-hook (vertico--exhibit): (wrong-type-argument listp 0)", stacktrace:

Debugger entered--Lisp error: (wrong-type-argument listp 0)
  read-extended-command--affixation((#("cd" 0 1 (face (completions-first-difference))) #("5x5" 0 1 (face (completions-first-difference))) #("arp" 0 1 (face (completions-first-difference))) #("dbx" 0 1 (face (completions-first-difference))) #("dig" 0 1 (face (completions-first-difference))) #("erc" 0 1 (face (completions-first-difference))) #("ert" 0 1 (face (completions-first-difference))) #("eww" 0 1 (face (completions-first-difference))) #("ftp" 0 1 (face (completions-first-difference))) #("gdb" 0 1 (face (completions-first-difference))) . 0))
  vertico--affixate((#("cd" 0 1 (face (completions-first-difference))) #("5x5" 0 1 (face (completions-first-difference))) #("arp" 0 1 (face (completions-first-difference))) #("dbx" 0 1 (face (completions-first-difference))) #("dig" 0 1 (face (completions-first-difference))) #("erc" 0 1 (face (completions-first-difference))) #("ert" 0 1 (face (completions-first-difference))) #("eww" 0 1 (face (completions-first-difference))) #("ftp" 0 1 (face (completions-first-difference))) #("gdb" 0 1 (face (completions-first-difference))) . 0))
  vertico--arrange-candidates()
  #<subr vertico--exhibit>()
  apply(#<subr vertico--exhibit> nil)
  (condition-case e (apply func args) ((debug error) (signal (car e) (cdr e))))
  force-debug(#<subr vertico--exhibit>)
  apply(force-debug #<subr vertico--exhibit> nil)
  vertico--exhibit()
  #<subr completing-read-default>("M-x " #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_54> #f(compiled-function (sym) #<bytecode -0x8bb31756a06ff21>) t nil extended-command-history nil nil)
  apply((#<subr completing-read-default> "M-x " #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_54> #f(compiled-function (sym) #<bytecode -0x8bb31756a06ff21>) t nil extended-command-history nil nil))
  vertico--advice(#<subr completing-read-default> "M-x " #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_54> #f(compiled-function (sym) #<bytecode -0x8bb31756a06ff21>) t nil extended-command-history nil nil)
  apply(vertico--advice #<subr completing-read-default> ("M-x " #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_54> #f(compiled-function (sym) #<bytecode -0x8bb31756a06ff21>) t nil extended-command-history nil nil))
  completing-read-default("M-x " #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_54> #f(compiled-function (sym) #<bytecode -0x8bb31756a06ff21>) t nil extended-command-history nil nil)
  read-extended-command-1("M-x " nil)
  read-extended-command()
  byte-code("\302\30\11\303 \10)E\207" [execute-extended-command--last-typed current-prefix-arg nil read-extended-command] 3)
  command-execute(execute-extended-command)

GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.37, cairo version 1.16.0) I was able to reproduce this error with Vertico versions 1.2 and 1.3.

minad commented 1 year ago

Thanks for the report. This issue is not present on Emacs 29. I cannot support Emacs 30 just yet, since it is not stable enough. This might be caused by some bytecode compiler regression. Do you use the newest commit of Emacs 30? You can also try to bisect Emacs 30 to locate where the problem was introduced and report it upstream, if there is indeed some regression.

minad commented 1 year ago

The nconc optimization is what I suspected. Are you Maks on the Emacs bug tracker? Thanks a lot for digging into this! https://lists.gnu.org/archive/html/bug-gnu-emacs/2023-04/msg01676.html

smaximov commented 1 year ago

Are you Maks on the Emacs bug tracker?

Nope, that's not me 😄

minad commented 1 year ago

Okay, I guess the report on the Emacs bug tracker was just a lucky coincidence then. Thanks anyway, and thanks to Maks! :smile:

minad commented 1 year ago

For reference - thankfully this issue has been fixed quickly by @mattiase in https://github.com/emacs-mirror/emacs/commit/1dcb737405a7a299fe6d01a5d9bd0c79328920b7.