Subject: bug#46834: 28.0.50; byte-compiling the standard counter closure fails

From: Pip Cet <[email-masked]>
Date: Sun, 28 Feb 2021 15:04:06 +0000

(My apologies if this is well-known, documented, or plain stupid on my
part, but I think it's an interesting gotcha. Feel free to close
immediately in those cases.)

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.