mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-30 09:00:31 -08:00
Fix byte-compiler crash for legal dynamic-binding code
This should really be taken care of by a syntax normalisation step in the frontend, but there is no such step for non-lexbind code yet. * lisp/emacs-lisp/byte-opt.el (byte-optimize-letX): Tolerate bindingsa without initialising expressions. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--test-cases): Add test cases.
This commit is contained in:
parent
e93bdfb6da
commit
45c32d7f00
2 changed files with 20 additions and 5 deletions
|
|
@ -1367,17 +1367,24 @@ See Info node `(elisp) Integer Basics'."
|
|||
(and (consp binding) (cadr binding)))
|
||||
bindings)
|
||||
,const)
|
||||
`(let* ,(butlast bindings) ,(cadar (last bindings)) ,const)))
|
||||
`(let* ,(butlast bindings)
|
||||
,@(and (consp (car (last bindings)))
|
||||
(cdar (last bindings)))
|
||||
,const)))
|
||||
|
||||
;; Body is last variable.
|
||||
(`(,head ,bindings ,(and var (pred symbolp) (pred (not keywordp))
|
||||
(pred (not booleanp))
|
||||
(guard (eq var (caar (last bindings))))))
|
||||
(`(,head ,(and bindings
|
||||
(let last-var (let ((last (car (last bindings))))
|
||||
(if (consp last) (car last) last))))
|
||||
,(and last-var ; non-linear pattern
|
||||
(pred symbolp) (pred (not keywordp)) (pred (not booleanp))))
|
||||
(if (eq head 'let)
|
||||
`(progn ,@(mapcar (lambda (binding)
|
||||
(and (consp binding) (cadr binding)))
|
||||
bindings))
|
||||
`(let* ,(butlast bindings) ,(cadar (last bindings)))))
|
||||
`(let* ,(butlast bindings)
|
||||
,@(and (consp (car (last bindings)))
|
||||
(cdar (last bindings))))))
|
||||
|
||||
(_ form)))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue