diff options
author | Mattias EngdegÄrd <mattiase@acm.org> | 2022-12-23 20:04:22 +0100 |
---|---|---|
committer | Mattias EngdegÄrd <mattiase@acm.org> | 2022-12-24 11:54:47 +0100 |
commit | 8bb8cc5b49a0cb681327ce9abe38266d5e26d19c (patch) | |
tree | cefdb13a4683c8325fe84f08b68bfb5b6b81ff14 /lisp/emacs-lisp/byte-opt.el | |
parent | cc2cc0c2971bf867283d1478bd0d99c2f420f982 (diff) | |
download | emacs-8bb8cc5b49a0cb681327ce9abe38266d5e26d19c.tar.gz emacs-8bb8cc5b49a0cb681327ce9abe38266d5e26d19c.tar.bz2 emacs-8bb8cc5b49a0cb681327ce9abe38266d5e26d19c.zip |
Fix condition-case body for-effect miscompilation
(condition-case x A (:success B)) should not compile A for-effect even
if the entire form is in for-effect context.
* lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker):
Don't optimise the condition-case body form for effect (potentially
discarding its value) if there is a success handler and a variable.
* test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--test-cases):
Add test cases.
Diffstat (limited to 'lisp/emacs-lisp/byte-opt.el')
-rw-r--r-- | lisp/emacs-lisp/byte-opt.el | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index 898dfffef63..ab35b0dde8f 100644 --- a/lisp/emacs-lisp/byte-opt.el +++ b/lisp/emacs-lisp/byte-opt.el @@ -410,7 +410,10 @@ for speeding up processing.") (`(condition-case ,var ,exp . ,clauses) `(,fn ,var ;Not evaluated. - ,(byte-optimize-form exp for-effect) + ,(byte-optimize-form exp + (if (assq :success clauses) + (null var) + for-effect)) ,@(mapcar (lambda (clause) (let ((byte-optimize--lexvars (and lexical-binding |