[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#46834: 28.0.50; byte-compiling the standard counter closure fails
From: |
Lars Ingebrigtsen |
Subject: |
bug#46834: 28.0.50; byte-compiling the standard counter closure fails |
Date: |
Mon, 01 Mar 2021 14:16:39 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Pip Cet <pipcet@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