Subject: bug#30070: 27.0.50; cl-print sometimes prints self-referencing objects as #1=#<thing>

From: Michael Heerdegen <[email-masked]>
Date: Wed, 10 Jan 2018 20:39:03 +0100

Hi,

my use case is like this:

--8<---------------cut here---------------start------------->8---
;; -*- lexical-binding: t -*-

(require 'cl-lib)
(require 'cl-print)

(cl-defstruct thing
  thing-object)

(cl-defmethod cl-print-object ((_object thing) stream)
  (princ "#<thing>" stream))

(let ((print-circle t))
  (cl-prin1-to-string
   (letrec ((me (make-thing :thing-object (lambda () me))))
     me)))
--8<---------------cut here---------------end--------------->8---

That gives me "#1=#<thing>".  That's weird because the printed
representation of the thing doesn't refer to itself.  This can happen in
real life: that the thing-object in the example is a closure referencing
the thing itself might be coincidence, so one can't assume that the
printed representation of a self-referential object always includes a
reference to the top-level object.

TIA,

Michael.

In GNU Emacs 27.0.50 (build 11, x86_64-pc-linux-gnu, GTK+ Version 3.22.26)
 of 2018-01-10 built on drachen
Repository revision: bf38966965384b07621839db892b90932b8754a6
Windowing system distributor 'The X.Org Foundation', version 11.0.11905000
System Description: Debian GNU/Linux testing (buster)