unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Mattias Engdegård" <mattias.engdegard@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Eli Zaretskii <eliz@gnu.org>,
	Jens Schmidt <jschmidt4gnu@vodafonemail.de>,
	66136@debbugs.gnu.org
Subject: bug#66136: 29.1; byte-compiler reports "misplaced interactive spec" with empty fct in lexical environment
Date: Sat, 23 Sep 2023 12:46:50 +0200	[thread overview]
Message-ID: <56BBBAB8-6DBA-45F8-A319-C5EDE5B15CC2@gmail.com> (raw)
In-Reply-To: <jwv4jjlgaab.fsf-monnier+emacs@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 1362 bytes --]

22 sep. 2023 kl. 23.39 skrev Stefan Monnier <monnier@iro.umontreal.ca>:

> I know Mattias played with this part of the code (mostly to try and
> figure what to do about the ordering of the various possible kinds of
> declarations, which is a related yet different issue).  Maybe he has
> a more informed opinion.

Can't lay much claim to that I'm afraid. In this case I'd just have macroexp-parse-body return an empty body and be done with it. Suggested patch attached.

Our triptych of meta-forms in function bodies (documentation, declare, interactive) is still not handled in a very principled or robust way. We keep parsing and re-parsing them in several places. I'm tempted to replace lambda with an intermediate form where these things are already parsed, early in the front-end (maybe even macroexpand-all).

There are all sorts of little annoyances, such as:

- if nothing comes after a (literal) doc string, the doc string also becomes the function body
- `declare` is only allowed in named definitions because it is macro-expanded very early, so we have no way of annotating lambda expressions
- not sure :documentation is handled correctly everywhere since it's a late addition
- that 'misplaced interactive spec' warning shouldn't be emitted from the Lisp optimiser at all but fully handled in the front-end like all syntax errors


[-- Attachment #2: macroexp-parse-body.diff --]
[-- Type: application/octet-stream, Size: 837 bytes --]

diff --git a/lisp/emacs-lisp/macroexp.el b/lisp/emacs-lisp/macroexp.el
index f96e0d74026..3bf0222c40d 100644
--- a/lisp/emacs-lisp/macroexp.el
+++ b/lisp/emacs-lisp/macroexp.el
@@ -525,12 +525,15 @@ macroexpand--all-toplevel
 (defun macroexp-parse-body (body)
   "Parse a function BODY into (DECLARATIONS . EXPS)."
   (let ((decls ()))
-    (while (and (cdr body)
+    (while (and body
                 (let ((e (car body)))
                   (or (stringp e)
                       (memq (car-safe e)
                             '(:documentation declare interactive cl-declare)))))
       (push (pop body) decls))
+    (when (and (null body) (stringp (car decls)))
+      ;; No body but a literal doc string: move it back to the body.
+      (push (pop decls) body))
     (cons (nreverse decls) body)))
 
 (defun macroexp-progn (exps)

  parent reply	other threads:[~2023-09-23 10:46 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-21 10:44 bug#66136: 29.1; byte-compiler reports "misplaced interactive spec" with empty fct in lexical environment Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-21 20:20 ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-21 21:39   ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-22  5:58     ` Eli Zaretskii
2023-09-22 14:59       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-22 21:26         ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-22 21:39           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-22 22:41             ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-23 10:46             ` Mattias Engdegård [this message]
2023-09-23 16:08               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-23 16:43                 ` Mattias Engdegård
2023-09-23 19:01                   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-24 10:42                     ` Mattias Engdegård
2023-09-24 15:42                       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-23 19:19               ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-23 22:31                 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-25 10:24                 ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-25 13:22                   ` Mattias Engdegård

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56BBBAB8-6DBA-45F8-A319-C5EDE5B15CC2@gmail.com \
    --to=mattias.engdegard@gmail.com \
    --cc=66136@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=jschmidt4gnu@vodafonemail.de \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).