From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs 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 Message-ID: <56BBBAB8-6DBA-45F8-A319-C5EDE5B15CC2@gmail.com> References: <58a3814205a241729c60ed277fa871b9@vodafonemail.de> <87o7hvs2gf.fsf@sappc2.fritz.box> <87leczrysc.fsf@sappc2.fritz.box> <838r8y92aw.fsf@gnu.org> <87y1gx528i.fsf@sappc2.fritz.box> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.15\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_C4FA516E-71ED-4564-B7E5-528FDC3707C1" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10404"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , Jens Schmidt , 66136@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Sep 23 12:48:12 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qk0BH-0002X8-Ns for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 23 Sep 2023 12:48:11 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qk0B0-0004gO-85; Sat, 23 Sep 2023 06:47:54 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qk0Ay-0004g8-0a for bug-gnu-emacs@gnu.org; Sat, 23 Sep 2023 06:47:52 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qk0Ax-0005m7-Ob for bug-gnu-emacs@gnu.org; Sat, 23 Sep 2023 06:47:51 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qk0B8-0006yY-Fq for bug-gnu-emacs@gnu.org; Sat, 23 Sep 2023 06:48:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 23 Sep 2023 10:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66136 X-GNU-PR-Package: emacs Original-Received: via spool by 66136-submit@debbugs.gnu.org id=B66136.169546603326643 (code B ref 66136); Sat, 23 Sep 2023 10:48:02 +0000 Original-Received: (at 66136) by debbugs.gnu.org; 23 Sep 2023 10:47:13 +0000 Original-Received: from localhost ([127.0.0.1]:37848 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qk0AL-0006vf-Di for submit@debbugs.gnu.org; Sat, 23 Sep 2023 06:47:13 -0400 Original-Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]:61706) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qk0AH-0006vR-7C for 66136@debbugs.gnu.org; Sat, 23 Sep 2023 06:47:12 -0400 Original-Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-5031426b626so5403368e87.3 for <66136@debbugs.gnu.org>; Sat, 23 Sep 2023 03:46:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695466012; x=1696070812; darn=debbugs.gnu.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:sender:from:to:cc:subject:date:message-id:reply-to; bh=YYTzlA+atGMGH0QRbg9lBiW+vgfkv3/wVfYnau8M62I=; b=fDcIs2JufQlmcOa1K+mPIFESjvdlW9TMJAqb82/4CU2KyJdGZs3vinkqf0X2LNHB/+ 2dIZf2Y3Ft+PU1QYvxkDImci1TiEx8FvduTBrHMGFilaOzmxtJf+w1BEWM8lOzy+Hvgj cXcbZbXGhc75dzlpuvl9pmWaOJG0XiVY9YhciopLOliYOD+1AtnHzHJZNJ+3UolepJ9Y +ia6+q/daks9Q6S3k/hUH71mU6MfCrWJbjkY8hyZQG/wje5JfUi/WzN8l91NP23z1YDs Dvg+gK0msAyWHDfQDn+5MHxGc5fkxAxVnE+C34icGQ4vU1rJirBKnwp/q8Y+EIYANYVn xahQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695466012; x=1696070812; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=YYTzlA+atGMGH0QRbg9lBiW+vgfkv3/wVfYnau8M62I=; b=Z2ZTwe1BD2ROKptjD2Xnm5XJe5yI0PBtA/nc2M4HoGdofARvYuTNBZKKB90XZWPwmn o9g4PQQS4rzWScPQpXYRLJJCjG8Z2M+rzO9N+znsUYAuwKgcvl2Djjcv2kvsnTWvdgxy a1gLSy1dGUItrT+PBiTmWEFpdynaABwFSF7lllTCrGfRIaY967122+tYU2bf/t/V57+P /WSZ/ozHaLb6Zc6OQ6YqdHu2bKleOWYNxqKqRybXvh+DzpZmkhnKxeQJpYrAUN6MqWfF PsMwizIcYMiiJTGBuOhrAkEcvb0F+ous2pa7NdZutaV9phwFuIXjsu+wkvMdoHE4cmk1 dOYw== X-Gm-Message-State: AOJu0YywPovU4nNdx2rg8RGSXlm/3U+/WJCRtjAh6MMV6ejAWPOTZzFA ZOXeVFia5VJdRkU2ZxDmNyc= X-Google-Smtp-Source: AGHT+IFsOtDLJjgWVM3EIiWu/AblDmmiv4mrjxGxcsF24Vl27bLNNlEPZJC9w6qaX8+HBayGdpdcUg== X-Received: by 2002:a05:6512:12cb:b0:503:3644:4a99 with SMTP id p11-20020a05651212cb00b0050336444a99mr2044602lfg.51.1695466011640; Sat, 23 Sep 2023 03:46:51 -0700 (PDT) Original-Received: from smtpclient.apple (c188-150-165-235.bredband.tele2.se. [188.150.165.235]) by smtp.gmail.com with ESMTPSA id u14-20020ac2518e000000b004fe0fead9e2sm1053396lfi.165.2023.09.23.03.46.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 23 Sep 2023 03:46:51 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3654.120.0.1.15) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:271153 Archived-At: --Apple-Mail=_C4FA516E-71ED-4564-B7E5-528FDC3707C1 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 22 sep. 2023 kl. 23.39 skrev Stefan Monnier : > 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 --Apple-Mail=_C4FA516E-71ED-4564-B7E5-528FDC3707C1 Content-Disposition: attachment; filename=macroexp-parse-body.diff Content-Type: application/octet-stream; x-unix-mode=0644; name="macroexp-parse-body.diff" Content-Transfer-Encoding: 7bit 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) --Apple-Mail=_C4FA516E-71ED-4564-B7E5-528FDC3707C1--