diff options
| author | Mattias EngdegÄrd | 2021-04-09 18:59:09 +0200 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2021-04-09 19:20:55 +0200 |
| commit | 59342f689eaa4839b0fc15351ae48b4f1074a6fc (patch) | |
| tree | d0778dc9d0ce81fba4ec9e8b36797ce946d73497 | |
| parent | b7a7e879d02570cbf74aa87686b6b0ed4e6b0c3b (diff) | |
| download | emacs-59342f689eaa4839b0fc15351ae48b4f1074a6fc.tar.gz emacs-59342f689eaa4839b0fc15351ae48b4f1074a6fc.zip | |
Fix condition-case optimiser bug
* lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker): Don't
perform incorrect optimisations when a condition-case variable shadows
another lexical variable.
* test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--test-cases):
New test case.
| -rw-r--r-- | lisp/emacs-lisp/byte-opt.el | 10 | ||||
| -rw-r--r-- | test/lisp/emacs-lisp/bytecomp-tests.el | 6 |
2 files changed, 14 insertions, 2 deletions
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index db8d825cfec..e5265375314 100644 --- a/lisp/emacs-lisp/byte-opt.el +++ b/lisp/emacs-lisp/byte-opt.el | |||
| @@ -528,8 +528,14 @@ Same format as `byte-optimize--lexvars', with shared structure and contents.") | |||
| 528 | `(condition-case ,var ;Not evaluated. | 528 | `(condition-case ,var ;Not evaluated. |
| 529 | ,(byte-optimize-form exp for-effect) | 529 | ,(byte-optimize-form exp for-effect) |
| 530 | ,@(mapcar (lambda (clause) | 530 | ,@(mapcar (lambda (clause) |
| 531 | `(,(car clause) | 531 | (let ((byte-optimize--lexvars |
| 532 | ,@(byte-optimize-body (cdr clause) for-effect))) | 532 | (and lexical-binding |
| 533 | (if var | ||
| 534 | (cons (list var t) | ||
| 535 | byte-optimize--lexvars) | ||
| 536 | byte-optimize--lexvars)))) | ||
| 537 | (cons (car clause) | ||
| 538 | (byte-optimize-body (cdr clause) for-effect)))) | ||
| 533 | clauses)))) | 539 | clauses)))) |
| 534 | 540 | ||
| 535 | (`(unwind-protect ,exp . ,exps) | 541 | (`(unwind-protect ,exp . ,exps) |
diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el b/test/lisp/emacs-lisp/bytecomp-tests.el index 1953878d6f5..94e33a7770e 100644 --- a/test/lisp/emacs-lisp/bytecomp-tests.el +++ b/test/lisp/emacs-lisp/bytecomp-tests.el | |||
| @@ -431,6 +431,12 @@ | |||
| 431 | 431 | ||
| 432 | (let ((x 2)) | 432 | (let ((x 2)) |
| 433 | (list (or (bytecomp-test-identity 'a) (setq x 3)) x)) | 433 | (list (or (bytecomp-test-identity 'a) (setq x 3)) x)) |
| 434 | |||
| 435 | (let* ((x 1) | ||
| 436 | (y (condition-case x | ||
| 437 | (/ 1 0) | ||
| 438 | (arith-error x)))) | ||
| 439 | (list x y)) | ||
| 434 | ) | 440 | ) |
| 435 | "List of expressions for cross-testing interpreted and compiled code.") | 441 | "List of expressions for cross-testing interpreted and compiled code.") |
| 436 | 442 | ||