Clojure

clojure.pprint/code-dispatch breaks on certain types of anonymous functions

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: Release 1.5
  • Fix Version/s: None
  • Component/s: None
  • Labels:

Description

(with-out-str 
  (with-pprint-dispatch code-dispatch 
                        (pp/pprint (read-string "(fn* [x] x)"))))

breaks because the format string here: https://github.com/clojure/clojure/blob/master/src/clj/clojure/pprint/dispatch.clj#L378 expects a sequence. In the case of (fn* [x] x) it is passed a symbol.

Activity

Devin Walters made changes -
Field Original Value New Value
Description {{(with-out-str (with-pprint-dispatch code-dispatch (pp/pprint (read-string "(fn* [x] x)"))))}} breaks because the format string here: https://github.com/clojure/clojure/blob/master/src/clj/clojure/pprint/dispatch.clj#L378 expects a sequence. In the case of (fn* [x] x) it is passed a symbol.
{noformat}
(with-out-str (with-pprint-dispatch code-dispatch (pp/pprint (read-string "(fn* [x] x)"))))
{noformat}
breaks because the format string here: https://github.com/clojure/clojure/blob/master/src/clj/clojure/pprint/dispatch.clj#L378 expects a sequence. In the case of (fn* [x] x) it is passed a symbol.
Devin Walters made changes -
Description
{noformat}
(with-out-str (with-pprint-dispatch code-dispatch (pp/pprint (read-string "(fn* [x] x)"))))
{noformat}
breaks because the format string here: https://github.com/clojure/clojure/blob/master/src/clj/clojure/pprint/dispatch.clj#L378 expects a sequence. In the case of (fn* [x] x) it is passed a symbol.
{noformat}
(with-out-str
  (with-pprint-dispatch code-dispatch
                        (pp/pprint (read-string "(fn* [x] x)"))))
{noformat}
breaks because the format string here: https://github.com/clojure/clojure/blob/master/src/clj/clojure/pprint/dispatch.clj#L378 expects a sequence. In the case of (fn* [x] x) it is passed a symbol.
Andy Fingerhut made changes -
Fix Version/s Release 1.5 [ 10150 ]
Hide
Jean Niklas L'orange added a comment -

I think the main "issue" here resides within the undocumented functionality of fn*. (fn* [x] x) is a semantically working function, but (fn [x] x) expands into (fn* ([x] x)). Anonymous function literals expand into (fn* [gensyms] (...)), and as such, it also accepts expressions like (fn* [x] x). Should pprint pretty print expressions which has used fn* directly, or should it "just" ignore it?

Show
Jean Niklas L'orange added a comment - I think the main "issue" here resides within the undocumented functionality of fn*. (fn* [x] x) is a semantically working function, but (fn [x] x) expands into (fn* ([x] x)). Anonymous function literals expand into (fn* [gensyms] (...)), and as such, it also accepts expressions like (fn* [x] x). Should pprint pretty print expressions which has used fn* directly, or should it "just" ignore it?
Alex Miller made changes -
Labels print
Alex Miller made changes -
Priority Major [ 3 ] Minor [ 4 ]

People

Vote (1)
Watch (2)

Dates

  • Created:
    Updated: