Fix local defvar scoping error (bug#46387)
This bug was introduced by the lexical variable constant propagation mechanism. It was discovered by Michael Heerdegen. * lisp/emacs-lisp/byte-opt.el (byte-optimize-let-form) (byte-optimize-body): Let the effects of a local defvar declaration be scoped by let and let*, not any arbitrary Lisp expression body (such as progn). * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--get-vars) (bytecomp-local-defvar): New test.
This commit is contained in:
parent
d9af416701
commit
f3ae26cb2a
2 changed files with 33 additions and 2 deletions
|
@ -698,7 +698,8 @@ Same format as `byte-optimize--lexvars', with shared structure and contents.")
|
|||
(append new-lexvars byte-optimize--lexvars))
|
||||
;; Walk the body expressions, which may mutate some of the records,
|
||||
;; and generate new bindings that exclude unused variables.
|
||||
(let* ((opt-body (byte-optimize-body (cdr form) for-effect))
|
||||
(let* ((byte-optimize--dynamic-vars byte-optimize--dynamic-vars)
|
||||
(opt-body (byte-optimize-body (cdr form) for-effect))
|
||||
(bindings nil))
|
||||
(dolist (var let-vars)
|
||||
;; VAR is (NAME EXPR [KEEP [VALUE]])
|
||||
|
@ -730,7 +731,6 @@ Same format as `byte-optimize--lexvars', with shared structure and contents.")
|
|||
;; all-for-effect is true. returns a new list of forms.
|
||||
(let ((rest forms)
|
||||
(result nil)
|
||||
(byte-optimize--dynamic-vars byte-optimize--dynamic-vars)
|
||||
fe new)
|
||||
(while rest
|
||||
(setq fe (or all-for-effect (cdr rest)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue