GNU bug report logs -
#46834
28.0.50; byte-compiling the standard counter closure fails
Previous Next
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
View this message in rfc822 format
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.