GNU bug report logs - #46834
28.0.50; byte-compiling the standard counter closure fails

Previous Next

Package: emacs;

Reported by: Pip Cet <pipcet <at> gmail.com>

Date: Sun, 28 Feb 2021 18:08:02 UTC

Severity: normal

Found in version 28.0.50

Done: Pip Cet <pipcet <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Pip Cet <pipcet <at> gmail.com>
Cc: 46834 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#46834: 28.0.50; byte-compiling the standard counter closure
 fails
Date: Mon, 01 Mar 2021 14:16:39 +0100
Pip Cet <pipcet <at> gmail.com> writes:

>> Steps to reproduce from emacs -Q:
>> Evaluate the following in a lexically-bound Emacs Lisp buffer:
>>
>> (byte-compile (let ((l 0)) (lambda () (cl-incf l))))
>>
>> Expected result:
>>
>> A byte code object which will increment its return value by one every
>> time it is called.
>>
>> Actual result:
>>
>> A byte code object which always returns 1.

Huh, that's such a standard example of using closures that it's
surprising that we haven't tripped on this before...  but I guess we
don't really write code like that much in Emacs.  (I can confirm that
the test case doesn't work in Emacs 28.)

> Patch attached. I've looked through the generated bytecode for all of
> lisp/ and there appear to be no significant differences.

I've added Stefan M to the CCs; perhaps he has some comments.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




This bug report was last modified 4 years and 85 days ago.

Previous Next


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