Welcome! Please see the About page for a little more info on how this works.

0 votes
in Printing by

With print-dup true, if an object being printed has a metadata map with only a :tag key, the printer renders it as "^value". This can cause an IllegalArgumentException if you try to read the printed string back in, in some circumstances. E.g.

user=> (read-string (let [ge (with-meta (gensym) {:tag Object})] (binding [*print-dup* true] (pr-str ge)))) IllegalArgumentException Metadata must be Symbol,Keyword,String or Map clojure.lang.LispReader$MetaReader.invoke (LispReader.java:732)

This is causing problems with sleight/riddley's (link: 1) handling of the (case) macro, which drops a type-hint on a gensym it incorporates in the form it returns. When sleight tries to reserialize a macroexpanded (case) form from riddley, it fails as demonstrated above. E.g.

user=> (read-string (binding [*print-dup* true] (pr-str (macroexpand '(case 1 1 1))))) user=> IllegalArgumentException Metadata must be Symbol,Keyword,String or Map clojure.lang.LispReader$MetaReader.invoke (LispReader.java:732)

The attached patch corrects this by making core_print.clj's print-meta always print out the full metadata map if print-dup is true. The patch also contains a test for this case.

(link: 1) https://github.com/ztellman/sleight https://github.com/ztellman/riddley

3 Answers

0 votes
by

Comment made by: coventry

Corresponding bug on sleight: https://github.com/ztellman/sleight/issues/5

0 votes
by

Comment made by: jafingerhut

Patch 0001-Don-t-use-shorthand-for-typehints-when-print-dup.patch dated Oct 2 2013 no longer applied cleanly to latest master after some commits were made to Clojure on Aug 29, 2014. It did apply cleanly before that day.

I have not checked how easy or difficult it might be to update this patch.

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-1275 (reported by coventry)
...