We're updating the issue view to help you get more done. 

pprint issues infinite output for a protocol

Description

Using pprint with a protocol name generates an unending stream of output. pprint appears to recurse through the Var reference as the value of the :var key in the protocol definition itself.

To reproduce:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 user=> (defprotocol Foo (foo-you [this])) Foo user=> (prn Foo) {:on user.Foo, :on-interface user.Foo, :sigs {:foo-you {:name foo-you, :arglists ([this]), :doc nil}}, :var #'user/Foo, :method-map {:foo-you :foo-you}, :method-builders {#'user/foo-you #object[user$eval1261$fn__1262 0x629ea441 "user$eval1261$fn__1262@629ea441"]}} user=> (pprint Foo) {:on user.Foo, :on-interface user.Foo, :sigs {:foo-you {:doc nil, :arglists ([this]), :name foo-you}}, :var #<Var@6a3b02d8: {:on user.Foo, :on-interface user.Foo, :sigs {:foo-you {:doc nil, :arglists ([this]), :name foo-you}}, :var #<Var@6a3b02d8: {:on user.Foo, :on-interface user.Foo, :sigs {:foo-you {:doc nil, :arglists ([this]), :name foo-you}}, :var #<Var@6a3b02d8: {:on user.Foo, :on-interface user.Foo, :sigs {:foo-you {:doc nil, :arglists ([this]), :name foo-you}}, :var #<Var@6a3b02d8: {:on user.Foo, :on-interface user.Foo, :sigs {:foo-you {:doc nil, :arglists ([this]), :name foo-you}}, :var ;; forever

Approach: Add a dispatch method which doesn't deref the Var

1 2 3 4 5 6 7 8 9 10 11 12 13 14 user=> (defprotocol Foo (foo-you [this])) Foo user=> (prn Foo) {:on user.Foo, :on-interface user.Foo, :sigs {:foo-you {:name foo-you, :arglists ([this]), :doc nil}}, :var #'user/Foo, :method-map {:foo-you :foo-you}, :method-builders {#'user/foo-you #object[user$eval10$fn__11 0x2452a793 "user$eval10$fn__11@2452a793"]}} user=> (pprint Foo) {:on user.Foo, :on-interface user.Foo, :sigs {:foo-you {:name foo-you, :arglists ([this]), :doc nil}}, :var #'user/Foo, :method-map {:foo-you :foo-you}, :method-builders {#'user/foo-you #object[user$eval10$fn__11 0x2452a793 "user$eval10$fn__11@2452a793"]}} nil

Patch: CLJ-1565.patch
Screened by: Alex Miller

Environment

None

Status

Assignee

Unassigned

Reporter

Michael Nygard

Labels

Approval

Ok

Patch

Code

Fix versions

Affects versions

Release 1.6

Priority

Major