for was not emitting kv pairs in cljs because of extra compiler metadata, fix #13

This commit is contained in:
Christophe Grand 2017-03-28 16:25:35 +02:00
parent 5ea2d1b3d3
commit 362febaf5f
3 changed files with 6 additions and 3 deletions

View file

@ -21,7 +21,7 @@ Transducing contexts: `transjuxt` (for performing several transductions in a sin
Add this dependency to your project: Add this dependency to your project:
```clj ```clj
[net.cgrand/xforms "0.9.1"] [net.cgrand/xforms "0.9.2"]
``` ```
```clj ```clj

View file

@ -1,4 +1,4 @@
(defproject net.cgrand/xforms "0.9.1" (defproject net.cgrand/xforms "0.9.2"
:description "Extra transducers for Clojure" :description "Extra transducers for Clojure"
:url "https://github.com/cgrand/xforms" :url "https://github.com/cgrand/xforms"
:license {:name "Eclipse Public License" :license {:name "Eclipse Public License"

View file

@ -12,6 +12,9 @@
(macros/deftime (macros/deftime
(defn- no-user-meta? [x]
(= {} (dissoc (or (meta x) {}) :file :line :column :end-line :end-column)))
(defmacro for (defmacro for
"Like clojure.core/for with the first expression being replaced by % (or _). Returns a transducer. "Like clojure.core/for with the first expression being replaced by % (or _). Returns a transducer.
When the first expression is not % (or _) returns an eduction." When the first expression is not % (or _) returns an eduction."
@ -40,7 +43,7 @@
nested-reduceds (core/for [[expr binding] rpairs nested-reduceds (core/for [[expr binding] rpairs
:when (not (keyword? binding))] :when (not (keyword? binding))]
`reduced) `reduced)
body (build `(let [acc# (~rf ~acc ~@(if (and (pair? body-expr) (nil? (meta body-expr))) body (build `(let [acc# (~rf ~acc ~@(if (and (pair? body-expr) (no-user-meta? body-expr))
body-expr body-expr
[body-expr]))] [body-expr]))]
(if (reduced? acc#) (if (reduced? acc#)