FORMAT/PPRINT-LOGICAL-BLOCK of CONDITIONs ignoring *PRINT-CIRCLE*

Bug #308948 reported by Nikodemus Siivola
2
Affects Status Importance Assigned to Milestone
SBCL
Triaged
Medium
Unassigned

Bug Description

  In sbcl-0.9.13.34,
    (defparameter *c*
      (make-condition 'simple-error
                      :format-control "ow... ~S"
                      :format-arguments '(#1=(#1#))))
    (setf *print-circle* t *print-level* 4)
    (format nil "~@<~A~:@>" *c*)
  gives
    "ow... (((#)))"
  where I (WHN) believe the correct result is "ow... #1=(#1#)",
  like the result from (PRINC-TO-STRING *C*). The question of
  what the correct result is is complicated by the hairy text in
  the Hyperspec "22.3.5.2 Tilde Less-Than-Sign: Logical Block",
    Other than the difference in its argument, ~@<...~:> is
    exactly the same as ~<...~:> except that circularity detection
    is not applied if ~@<...~:> is encountered at top level in a
    format string.
  But because the odd behavior happens even without the at-sign,
    (format nil "~<~A~:@>" (list *c*)) ; => "ow... (((#)))"
  and because something seemingly similar can happen even in
  PPRINT-LOGICAL-BLOCK invoked directly without FORMAT,
    (pprint-logical-block (*standard-output* '(some nonempty list))
      (format *standard-output* "~A" '#1=(#1#)))
  (which prints "(((#)))" to *STANDARD-OUTPUT*), I don't think
  that the 22.3.5.2 trickiness is fundamental to the problem.

  My guess is that the problem is related to the logic around the MODE
  argument to CHECK-FOR-CIRCULARITY, but I haven't reverse-engineered
  enough of the intended meaning of the different MODE values to be
  confident of this.

Tags: printer
Changed in sbcl:
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Nikodemus Siivola (nikodemus) wrote :

Addenda: TRACE confuses circularity detection -- which doesn't exactly make it easier to understand what is going on.

Changed in sbcl:
status: Confirmed → Triaged
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.