GNU bug report logs - #67568
Emacs master: Bug in byte compiler when there's an unused parameter.

Previous Next

Package: emacs;

Reported by: Alan Mackenzie <acm <at> muc.de>

Date: Fri, 1 Dec 2023 12:51:01 UTC

Severity: normal

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


Message #14 received at 67568 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Dmitry Gutov <dmitry <at> gutov.dev>
Cc: acm <at> muc.de, Stefan Monnier <monnier <at> iro.umontreal.ca>,
 67568 <at> debbugs.gnu.org
Subject: Re: bug#67568: Emacs master: Bug in byte compiler when there's an
 unused parameter.
Date: Fri, 1 Dec 2023 15:22:24 +0000
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).




This bug report was last modified 1 year and 227 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.