Subject: Re: bug#35758: Build failure with Emacs master branch
From: Tassilo Horn <[email-masked]>
To: Joseph Mingrone <[email-masked]>
Cc: [email-masked]
Date: Fri, 17 May 2019 22:30:32 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Joseph Mingrone <[email-masked]> writes:

Hi Joseph,

> AUCTeX fails when building with recent commits from the Emacs' master
> branch (but builds fine with Emacs 26.2).  I see this with both AUCTeX
> 12.1 and from the HEAD of the repository.
>
> Here is a snippet of the error.
> ------------------------------------------------------------------------
> gmake[1]: Entering directory '/usr/home/jrm/scm/nm/auctex'
> rm -f preview-latex.el
> /usr/local/bin/emacs -batch -no-site-file -no-init-file --eval '(let ((generated-autoload-file (expand-file-name "preview-latex.el"))) (update-file-autoloads "preview.el")(save-buffers-kill-emacs t))' ; \
> test -r preview-latex.el || { \
>   echo ";; Auto-generated preview-latex.el" > preview-latex.el ; \
>   echo "
>         " >> preview-latex.el ; \
>   /usr/local/bin/emacs -batch -no-site-file -no-init-file --eval '(let ((generated-autoload-file (expand-file-name "preview-latex.el"))) (update-file-autoloads "preview.el")(save-buffers-kill-emacs t))' ; \
> }
> preview.el:0:0: error: wrong-type-argument: (stringp nil)
> preview.el:0:0: error: wrong-type-argument: (stringp nil)
> ------------------------------------------------------------------------

I could reproduce that once with a newly started emacs with this recipe
in *scratch*:

--8<---------------cut here---------------start------------->8---
(let ((default-directory "~/Repos/el/auctex")
      (generated-autoload-file (expand-file-name "auto-loads.el")))
  (message "%S" command-line-args-left)
  (mapcar
   (function update-file-autoloads)
   (list "tex.el")))
--8<---------------cut here---------------end--------------->8---

When trying to edebug `update-file-autoloads' and the functions called
from that, the bug magically disappeared until I started a new emacs...

I don't really know what exactly changed but I suspect it has something
to do with lexical binding `default-value'.  Normally,

(defvar y nil)
(defun dvy ()
  (default-value 'y))
(let ((y 17))
  (dvy)) ;; => 17

but in our case, the let-bound value of `generated-autoload-file' hasn't
been there in `autoload-file-load-name', and that's where the error came
from (I think!  As soon as I tried to edebug it, the error magically
appeared).

Anyway, `update-file-autoloads' allows to specify the autoload file as
third argument instead of binding `generated-autoload-file', so I'm
using that now.  Pushed to master.  I'm closing this issue.

Thanks for the report,
Tassilo