diff options
author | Mattias EngdegÄrd <mattiase@acm.org> | 2021-04-08 22:48:02 +0200 |
---|---|---|
committer | Mattias EngdegÄrd <mattiase@acm.org> | 2021-04-09 10:55:37 +0200 |
commit | 612d73167688a9a9742478373933c4af5e3f8720 (patch) | |
tree | 9ce32377cfe6d79e0fce8e02b7cef47063e05460 /test/lisp/emacs-lisp/cl-macs-tests.el | |
parent | 1d42f4800bc3759ac961b97b2a66d4b73e520eb5 (diff) | |
download | emacs-612d73167688a9a9742478373933c4af5e3f8720.tar.gz emacs-612d73167688a9a9742478373933c4af5e3f8720.tar.bz2 emacs-612d73167688a9a9742478373933c4af5e3f8720.zip |
Self-TCO in `condition-case` error handlers
* lisp/emacs-lisp/cl-macs.el (cl--self-tco): Recognise
`condition-case` handlers as being in the tail position.
* test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs--labels):
Extend test.
Diffstat (limited to 'test/lisp/emacs-lisp/cl-macs-tests.el')
-rw-r--r-- | test/lisp/emacs-lisp/cl-macs-tests.el | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/test/lisp/emacs-lisp/cl-macs-tests.el b/test/lisp/emacs-lisp/cl-macs-tests.el index dd6487603d3..5c3e603b92e 100644 --- a/test/lisp/emacs-lisp/cl-macs-tests.el +++ b/test/lisp/emacs-lisp/cl-macs-tests.el @@ -629,14 +629,24 @@ collection clause." (let (n1) (and xs (progn (setq n1 (1+ n)) - (len2 (cdr xs) n1))))))) + (len2 (cdr xs) n1)))))) + ;; Tail call in error handler. + (len3 (xs n) + (if xs + (condition-case nil + (/ 1 0) + (arith-error (len3 (cdr xs) (1+ n)))) + n))) (should (equal (len nil 0) 0)) (should (equal (len2 nil 0) 0)) + (should (equal (len3 nil 0) 0)) (should (equal (len list-42 0) 42)) (should (equal (len2 list-42 0) 42)) + (should (equal (len3 list-42 0) 42)) ;; Should not bump into stack depth limits. (should (equal (len list-42k 0) 42000)) - (should (equal (len2 list-42k 0) 42000)))) + (should (equal (len2 list-42k 0) 42000)) + (should (equal (len3 list-42k 0) 42000)))) ;; Check that non-recursive functions are handled more efficiently. (should (pcase (macroexpand '(cl-labels ((f (x) (+ x 1))) (f 5))) |