Subject: bug#66136: 29.1; byte-compiler reports "misplaced interactive spec" with empty fct in lexical environment

From: Jens Schmidt <[email-masked]>
Date: Thu, 21 Sep 2023 22:20:32 +0200

Smaller test case is

-------------------- foo.el --------------------
;;; -*- lexical-binding: t -*-

(defun delete-process@emacs-fix (arg)
  "Allows interactive calls."
  (interactive "^P"))
-------------------- foo.el --------------------

And even smaller might be (but I cannot interpret the results for sure)
that

-------------------- bad case --------------------
(byte-compile-preprocess
 '(defun delete-process@emacs-fix
    (arg)
    "Allows interactive calls."
    (interactive "^P")))

=>

(defalias 'delete-process@emacs-fix
  #'(lambda (arg) "Allows interactive calls."
      (macroexp--funcall-if-compiled
       '#[0 "\300:\203\0\303\304\300\"\202\0\304\300!\205\0\305\302\306\301#\207"
	  [lexical "Unused lexical argument ‘arg’" arg apply
		   byte-compile-warning-enabled-p byte-compile-warn-x
		   "%s"]
	  4...])
      ;; this dangling interactive form ultimately seems to
      ;; trigger the warning
      (interactive "^P")))
-------------------- bad case --------------------

while

-------------------- good case --------------------
(byte-compile-preprocess
 '(defun delete-process@emacs-fix
    (arg)
    "Allows interactive calls."
    (interactive "^P")
    nil))

=>

(defalias 'delete-process@emacs-fix
  #'(lambda (arg) "Allows interactive calls."
      (interactive "^P")
      (macroexp--funcall-if-compiled
       '#[0 "\300:\203\0\303\304\300\"\202\0\304\300!\205\0\305\302\306\301#\207"
	  [lexical "Unused lexical argument ‘arg’" arg apply
		   byte-compile-warning-enabled-p byte-compile-warn-x
		   "%s"]
	  4])
      nil))
-------------------- good case --------------------

so `byte-compile-preprocess' could be the culprit here, inserting the
warning wrapped into the `macroexp--funcall-if-compiled' in the wrong
place.