Reserialization after transformation can be unreadable due to CLJ-176 #4

coventry opened this Issue Sep 22, 2013 · 3 comments


None yet

2 participants


Test case: Put the following in sleight/tst.clj:

(defmacro test [x])

Run the following in the sleight.core ns:

(require '[riddley.walk :as rw])
  (wrap-reader {:transform #(rw/walk-exprs symbol? identity %)})
  (load "tst")
  (finally (unwrap-reader)))

This gives the error message "CompilerException java.lang.IllegalArgumentException: No matching method found: create". Reason can be seen by tracing (apply pr-str vals) in sleight.reader/line-preserving-pr-str:

"TRACE serialising: \"(do (def ^#=(clojure.lang.PersistentArrayMap/create {:arglists (quote (#=(clojure.lang.APersistentVector$SubVector/create [x])))}) ^#=(clojure.lang.PersistentArrayMap/create {:arglists (quote (#=(clojure.lang.APersistentVector$SubVector/create [x])))}) test (fn* ([&form &env x]))) (. (var test) ^#=(clojure.lang.PersistentArrayMap/create {:line #=(java.lang.Integer. \\\"465\\\"), :column #=(java.lang.Integer. \\\"49\\\")}) ^#=(clojure.lang.PersistentArrayMap/create {:line #=(java.lang.Integer. \\\"465\\\"), :column #=(java.lang.Integer. \\\"49\\\")}) (setMacro)) (var test))\""

(Vast numbers of newlines deleted.) At least one of these literals can't be read. E.g.

user> #=(clojure.lang.APersistentVector$SubVector/create [x])
IllegalArgumentException No matching method found: create  clojure.lang.Reflector.invokeMatchingMethod (

This is probably related to CLJ-176 (see also). Perhaps this will be the compelling use case stu asks for. :-)

Best regards,


This seems like a terrible solution for the long haul, but explicitly adding a print-dup method for the offending class works around the issue for now.

Best regards,

diff --git a/src/sleight/reader.clj b/src/sleight/reader.clj
index 0245238..e619b04 100644
--- a/src/sleight/reader.clj
+++ b/src/sleight/reader.clj
@@ -66,6 +66,10 @@
              *print-dup* true]
      (apply pr-str vals)))

+(defmethod print-dup clojure.lang.APersistentVector$SubVector
+  [o w]
+  (print-method o w))

  (defn lazy-reader-seq [s]

Since SubVector is an IPersistentVector, I think we can fix this specific problem by just doing (into [] v) on any vector-like thing before printing it. Am I missing some reason this wouldn't work?

coventry commented Oct 3, 2013

In riddley? I guess that would work for this case.

@ztellman ztellman closed this Dec 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment