* lisp/emacs-lisp/cl-print.el (cl-print-object) <cons>: Push each
element of list being printed onto cl-print--currently-printing.
* test/lisp/emacs-lisp/cl-print-tests.el (cl-print-circle-2): New
test.
(cherry picked from commit
b8aa7ecf54c9b164a59f1b0e9f9fe90531dadd20)
(princ "(" stream)
(cl-print-object car stream)
(while (and (consp object)
- (not (if cl-print--number-table
- (numberp (gethash object cl-print--number-table))
- (memq object cl-print--currently-printing))))
+ (not (cond
+ (cl-print--number-table
+ (numberp (gethash object cl-print--number-table)))
+ ((memq object cl-print--currently-printing))
+ (t (push object cl-print--currently-printing)
+ nil))))
(princ " " stream)
(cl-print-object (pop object) stream))
(when object
(let ((print-circle t))
(should (equal "(#1=(a . #1#) #1#)" (cl-prin1-to-string x))))))
+(ert-deftest cl-print-circle-2 ()
+ ;; Bug#31146.
+ (let ((x '(0 . #1=(0 . #1#))))
+ (let ((print-circle nil))
+ (should (string-match "\\`(0 0 . #[0-9])\\'"
+ (cl-prin1-to-string x))))
+ (let ((print-circle t))
+ (should (equal "(0 . #1=(0 . #1#))" (cl-prin1-to-string x))))))
+
+
;;; cl-print-tests.el ends here.