Subject: Re: bug#68945: 30.0.50; loaddefs-generate--parse-file: Wrong type argument: symbolp, 63

From: Philip Kaludercic <[email-masked]>
Date: Tue, 06 Feb 2024 18:42:50 +0000

Brent Westbrook <[email-masked]> writes:

> Attempting to install the projectile package from melpa leads to the
> following (abbreviated) Backtrace:
>
> Debugger entered--Lisp error: (wrong-type-argument symbolp 63)

This appears to be related to commit that João made last November:

--8<---------------cut here---------------start------------->8---
commit 817140a852e79c5ef3cf7dc5e4c50aa710e8c4a2
Author: João Távora <[email-masked]>
Date:   Thu Nov 30 07:32:50 2023 -0600

    Fix prefix discovery for files with read-symbol-shorthands (bug#67325)
    
    In a previous commit, the local-variable read-symbol-shorthands is
    already read into the temporary buffer used for the autoload parsing
    aerobatics, so all we needed to do in 'l-g--compute-prefixes' is
    use 'read' to give 'read-symbol-shorthands' a chance to kick in.
    
    * lisp/emacs-lisp/loaddefs-gen.el
    (loaddefs-generate--compute-prefixes):

diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen.el
index bf5cd24f161..8aacbf406b6 100644
--- a/lisp/emacs-lisp/loaddefs-gen.el
+++ b/lisp/emacs-lisp/loaddefs-gen.el
@@ -499,7 +499,11 @@ loaddefs-generate--compute-prefixes
     (while (re-search-forward
             "^(\\(def[^ \t\n]+\\)[ \t\n]+['(]*\\([^' ()\"\n]+\\)[\n \t]" nil t)
       (unless (member (match-string 1) autoload-ignored-definitions)
-        (let ((name (match-string-no-properties 2)))
+        (let* ((name (match-string-no-properties 2))
+               ;; Consider `read-symbol-shorthands'.
+               (probe (let ((obarray (obarray-make)))
+                        (car (read-from-string name)))))
+          (setq name (symbol-name probe))
           (when (save-excursion
                   (goto-char (match-beginning 0))
                   (or (bobp)
--8<---------------cut here---------------end--------------->8---

and the fact that Projectile has this line

--8<---------------cut here---------------start------------->8---
(def-projectile-commander-method ?? "Commander help buffer."
--8<---------------cut here---------------end--------------->8---

where the `name' variable above gets bound to the string "??", that when
passed through `read-from-string' eventually gives us the character ??
(ASCII 63), which one cannot pass to `symbol-name'.  So it might be that

diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen.el
index 7eced43e735..0f82239da63 100644
--- a/lisp/emacs-lisp/loaddefs-gen.el
+++ b/lisp/emacs-lisp/loaddefs-gen.el
@@ -506,14 +506,15 @@ loaddefs-generate--compute-prefixes
                ;; Consider `read-symbol-shorthands'.
                (probe (let ((obarray (obarray-make)))
                         (car (read-from-string name)))))
-          (setq name (symbol-name probe))
-          (when (save-excursion
-                  (goto-char (match-beginning 0))
-                  (or (bobp)
-                      (progn
-                        (forward-line -1)
-                        (not (looking-at ";;;###autoload")))))
-            (push name prefs)))))
+          (when (symbolp probe)
+            (setq name (symbol-name probe))
+            (when (save-excursion
+                    (goto-char (match-beginning 0))
+                    (or (bobp)
+                        (progn
+                          (forward-line -1)
+                          (not (looking-at ";;;###autoload")))))
+              (push name prefs))))))
     (loaddefs-generate--make-prefixes prefs load-name)))
 
 (defun loaddefs-generate--rubric (file &optional type feature compile)

could fix the issue, but I am not too familiar with the code.  I've
CC'ed João to see if he has anything to add.

>   loaddefs-generate--compute-prefixes("projectile")
>   loaddefs-generate--parse-file("/home/brent/.emacs.d/elpa/projectile-20240205.1021/projectile.el" "/home/brent/.emacs.d/elpa/projectile-20240205.1021/projectile-autoloads.el" nil)
>   loaddefs-generate("/home/brent/.emacs.d/elpa/projectile-20240205.1021" "/home/brent/.emacs.d/elpa/projectile-20240205.1021/projectile-autoloads.el" nil "(add-to-list 'load-path (or (and load-file-name (directory-file-name (file-name-directory load-file-name))) (car load-path)))")
>   package-generate-autoloads(projectile "/home/brent/.emacs.d/elpa/projectile-20240205.1021")
>   package--make-autoloads-and-stuff(#s(package-desc :name projectile :version (20240205 1021) :summary "Manage and navigate projects in Emacs easily" :reqs ((emacs (25 1))) :kind tar :archive "melpa" :dir nil :extras ((:commit . "e45f0b0cc43fdc066e7971ff3ed3bf4c78015ed0") (:authors ("Bozhidar Batsov" . "[email-masked]")) (:maintainers ("Bozhidar Batsov" . "[email-masked]")) (:maintainer "Bozhidar Batsov" . "[email-masked]") (:keywords "project" "convenience") (:url . "https://github.com/bbatsov/projectile")) :signed nil) "/home/brent/.emacs.d/elpa/projectile-20240205.1021")
>
> I can replicate this with emacs -Q:
>
> (require 'package)
> (package-initialize)
> (add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
> (package-install 'projectile)
>
> However, I think the real issue is with loading the package, not the
> installation. I originally hit this when trying to load the package with
> use-package, but then hit this version when trying to uninstall and
> reinstall. use-package reports this instead:
>
> use-package-autoload-keymap: use-package: Cannot load package.el: projectile
>
> when I try to switch projects with my projectile-command-map.
>
> I noticed a couple of recent changes when grepping the git log for
> loaddefs (Feb 3), so I'm going to try to revert to a version prior to
> that to see if that helps.
>
> Let me know if you need any more info,
> Brent Westbrook
>
> Build info:
>
> In GNU Emacs 30.0.50 (build 2, x86_64-pc-linux-gnu, cairo version
>  1.18.0) of 2024-02-05 built on keystone
> Repository revision: 95c8bfb11ec82e67652e5903495c1fcb5c61ace2
> Repository branch: master
> Windowing system distributor 'The X.Org Foundation', version 11.0.12101011
> System Description: Arch Linux
>
> Configured using:
>  'configure --with-native-compilation --with-json --with-x-toolkit=no
>  --with-tree-sitter'
>
> Configured features:
> ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
> JSON LCMS2 LIBOTF LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY
> INOTIFY OLDXMENU PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
> TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM ZLIB
>
> Important settings:
>   value of $LANG: C.UTF-8
>   locale-coding-system: utf-8-unix