unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Dmitry Gutov <dmitry@gutov.dev>
Cc: acm@muc.de, Stefan Monnier <monnier@iro.umontreal.ca>,
	67568@debbugs.gnu.org
Subject: bug#67568: Emacs master: Bug in byte compiler when there's an unused parameter.
Date: Fri, 1 Dec 2023 15:22:24 +0000	[thread overview]
Message-ID: <ZWn6MIMSwRx2LqCe@ACM> (raw)
In-Reply-To: <1c2d9219-093c-0726-13ce-2c952f6e33ba@gutov.dev>

Hello again, Dmitry.

On Fri, Dec 01, 2023 at 15:06:23 +0200, Dmitry Gutov wrote:
> On 01/12/2023 14:49, Alan Mackenzie wrote:
> > On a recent Emacs master:

> > (i) emacs -Q
> > (ii) In*scratch*  enter the following:

> >      (byte-compile (lambda (x) "doc" "foo"))

> >    .
> > (iii) Enter C-u C-x C-e to evaluate the form.  The result looks like:

> >      #[257 "\300\207" [nil] 2 "doc

> >      (fn X)"]

> >    .  This is incorrect.  The only form in the constants vector is nil.
> >    It should be "foo".

> > (iv) Note that this only happens with the unused parameter x.  Without
> > it, the form compiles correctly.

> Might be a bug in the interpreter too?

> (funcall (lambda (x) "doc" "foo") 2)

> ;; => nil

I have a candidate for the buggy function, namely macroexp-parse-body.
It'd doc string reads "Parse a function BODY into (DECLARATIONS .  EXPS).",
but it's vague about what precisely a BODY is.  It's not clear, either,
what exactly is meant by DECLARATIONS.

What the function does is move strings (or :documentation forms) from the
head of BODY into DECLS.  So maybe DECLARATIONS is intended to be any
number of consecutive doc strings.  Exceptionally, if there is precisely
one string, it is not moved into DECLS.

When BODY is ("doc" "foo") as is the case here, both "doc" and "foo" get
moved from BODY to DECLS, leaving an empty BODY and a wrong DECLS.  The
return value is here (("doc" "foo") . nil), which is clearly wrong.  It
probably should be (("doc") . ("foo")).

-- 
Alan Mackenzie (Nuremberg, Germany).





  parent reply	other threads:[~2023-12-01 15:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-01 12:49 bug#67568: Emacs master: Bug in byte compiler when there's an unused parameter Alan Mackenzie
2023-12-01 13:06 ` Dmitry Gutov
2023-12-01 14:16   ` Alan Mackenzie
2023-12-01 15:22   ` Alan Mackenzie [this message]
2023-12-01 15:40     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-01 16:34       ` Alan Mackenzie
2023-12-03 15:55         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-03 16:21           ` Eli Zaretskii
2023-12-03 19:24             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-03 19:28               ` Eli Zaretskii

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=ZWn6MIMSwRx2LqCe@ACM \
    --to=acm@muc.de \
    --cc=67568@debbugs.gnu.org \
    --cc=dmitry@gutov.dev \
    --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).