]> git.eshelyaron.com Git - emacs.git/commit
Fix variable aliasing bytecode miscompilation (bug#67116)
authorMattias Engdegård <mattiase@acm.org>
Mon, 13 Nov 2023 10:49:32 +0000 (11:49 +0100)
committerMattias Engdegård <mattiase@acm.org>
Mon, 13 Nov 2023 11:16:37 +0000 (12:16 +0100)
commit1247dc87bab7ec56b05e87ab0ae8bf37aa90021b
treef580e28da784448fe68c5301907ebc4811eb377c
parent8090ab05434f39b73e6238ebc5ab8e4fcc52acf3
Fix variable aliasing bytecode miscompilation (bug#67116)

The compiler didn't cancel aliasing if the aliased variable was
modified in a variable binding in the same `let` that created
the alias.  For example,

 (let ((x A))
   (let ((y x)
         (z (setq x B)))
     y))

would incorrectly substitute y->x in the body form despite x being
already modified at that point, which normally should have cancelled
the aliasing.

Bug reported by Alan Mackenzie.

* lisp/emacs-lisp/byte-opt.el (byte-optimize--aliased-vars):
Now an alist that also contains the aliases; update the doc string.
* lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker):
* lisp/emacs-lisp/byte-opt.el (byte-optimize-let-form):
Detect aliasing early for `let`-bound variables as well.
* test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--test-cases):
Add test cases.
lisp/emacs-lisp/byte-opt.el
test/lisp/emacs-lisp/bytecomp-tests.el