Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(write) failes when sequence/transducer is passed. #30

Closed
kamituel opened this issue Nov 4, 2016 · 2 comments
Closed

(write) failes when sequence/transducer is passed. #30

kamituel opened this issue Nov 4, 2016 · 2 comments

Comments

@kamituel
Copy link

kamituel commented Nov 4, 2016

When using sequence with transducers, transit/write failes with an exception.

Consider:

(def transit-writer
  (transit/writer :json))

(defn transform-map
  [m]
  (assoc m :x 1))

(def data
  [{:a 1} {:a 1}])

(prn "p1. Regular map")
(prn (transit/write transit-writer (map transform-map data)))

(prn "p2. Transducer")
(prn (transit/write transit-writer (sequence (map transform-map) data)))

(prn "p3. Done")

Regular map (p1) will print just fine, however, p2 fails with an exception:

Uncaught Error: Cannot write 
    writer.maybeQuoted @ writer.js:464
    writer.marshalTop @ writer.js:471
    writer.Writer.write @ writer.js:501
    cognitect$transit$write @ transit.cljs?rel=1478250205512:256
    (anonymous function) @ core.cljs?rel=1478251095137:53

Because of that, obviously p3 never gets printed.

Latest transit: 0.8.239. I'm able to reproduce it on ClojureScript 1.9.293 (latest) as well as 1.9.76 (haven't tried other versions).

@kamituel
Copy link
Author

kamituel commented Nov 4, 2016

For completness:

;; Breaks too.
(prn (transit/write transit-writer (doall (sequence (map transform-map) data))))

;; Works fine.
(prn (transit/write transit-writer (vec (sequence (map transform-map) data))))

;; Works fine.
(prn (transit/write transit-writer (apply list (sequence (map transform-map) data))))

@swannodette
Copy link
Collaborator

I can't replicate this with the latest ClojureScript

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants