diff options
| author | Mattias EngdegÄrd | 2023-04-27 12:38:58 +0200 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2023-04-27 14:20:45 +0200 |
| commit | 1dcb737405a7a299fe6d01a5d9bd0c79328920b7 (patch) | |
| tree | 43af8f37e1185290b6a485ec936ad1463b4b7802 /test | |
| parent | 521386f9201d0cacfcc857f7ef7cc1e5e586705a (diff) | |
| download | emacs-1dcb737405a7a299fe6d01a5d9bd0c79328920b7.tar.gz emacs-1dcb737405a7a299fe6d01a5d9bd0c79328920b7.zip | |
Don't rewrite (nconc X nil) -> X for any X (bug#63103)
Since the last cdr of a non-terminal argument to `nconc` is
overwritten no matter its value:
(nconc (cons 1 2) nil) => (1)
a terminating nil arg cannot just be eliminated unconditionally.
* lisp/emacs-lisp/byte-opt.el (byte-optimize-nconc):
Only eliminate a terminal nil arg to `nconc` if preceded by
a nonempty proper list. Right now we only bother to prove this
for `(list ...)`, so that
(nconc (list 1 2 3) nil) -> (list 1 2 3)
* test/lisp/emacs-lisp/bytecomp-tests.el
(bytecomp-tests--test-cases): Add test cases.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/emacs-lisp/bytecomp-tests.el | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el b/test/lisp/emacs-lisp/bytecomp-tests.el index 9ade47331df..222065c2e4e 100644 --- a/test/lisp/emacs-lisp/bytecomp-tests.el +++ b/test/lisp/emacs-lisp/bytecomp-tests.el | |||
| @@ -766,6 +766,16 @@ inner loops respectively." | |||
| 766 | ((eq x 2) (setq y 'c))) | 766 | ((eq x 2) (setq y 'c))) |
| 767 | (list x y))))) | 767 | (list x y))))) |
| 768 | (mapcar fn (bytecomp-test-identity '(0 1 2 3 10 11)))) | 768 | (mapcar fn (bytecomp-test-identity '(0 1 2 3 10 11)))) |
| 769 | |||
| 770 | ;; `nconc' nil arg elimination | ||
| 771 | (nconc (list 1 2 3 4) nil) | ||
| 772 | (nconc (list 1 2 3 4) nil nil) | ||
| 773 | (let ((x (cons 1 (cons 2 (cons 3 4))))) | ||
| 774 | (nconc x nil)) | ||
| 775 | (let ((x (cons 1 (cons 2 (cons 3 4))))) | ||
| 776 | (nconc x nil nil)) | ||
| 777 | (let ((x (cons 1 (cons 2 (cons 3 4))))) | ||
| 778 | (nconc nil x nil (list 5 6) nil)) | ||
| 769 | ) | 779 | ) |
| 770 | "List of expressions for cross-testing interpreted and compiled code.") | 780 | "List of expressions for cross-testing interpreted and compiled code.") |
| 771 | 781 | ||