Details
-
Type:
Defect
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Completed
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Environment:cljsbuild 0.2.8
core.logic 0.8.0-beta2
Description
The following code:
(defn map-geto* [m k v]
(matche [m]
([[[k v] . _]])
([[_ . tail]] (map-geto* tail k v))))
(run* [q] (map-geto* (seq {:title "Blub" }) :title q))
works in Clojure as expected, returning ("Blub"). However in ClojureScript I get (_.0) instead. From what I can tell, this is because within the matche clause that matches [k v], both k and v are not being matched against the upper k and v, but rather create fresh variables instead.
I can work around the issue by writing the following:
(defn map-geto* [m k v]
(matche [m]
([[[k' v'] . _]] (== k k') (== v v'))
([[_ . tail]] (map-geto* tail k v))))
(run* [q] (map-geto* (seq {:title "Blub" }) :title q))
Is this intended behavior?
Activity
David Nolen
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Description |
The following code:
------------------------------ (defn map-geto* [m k v] (matche [m] ([[[k v] . _]]) ([[_ . tail]] (map-geto* tail k v)))) (run* [q] (map-geto* (seq {:title "Blub" }) :title q)) ------------------------------ works in Clojure as expected, returning ("Blub"). However in ClojureScript I get (_.0) instead. From what I can tell, this is because within the matche clause that matches [k v], both k and v are not being matched against the upper k and v, but rather create fresh variables instead. I can work around the issue by writing the following: ------------------------------ (defn map-geto* [m k v] (matche [m] ([[[k' v'] . _]] (== k k') (== v v')) ([[_ . tail]] (map-geto* tail k v)))) (run* [q] (map-geto* (seq {:title "Blub" }) :title q)) ------------------------------ Is this intended behavior? |
The following code:
{code} (defn map-geto* [m k v] (matche [m] ([[[k v] . _]]) ([[_ . tail]] (map-geto* tail k v)))) (run* [q] (map-geto* (seq {:title "Blub" }) :title q)) {code} works in Clojure as expected, returning ("Blub"). However in ClojureScript I get (_.0) instead. From what I can tell, this is because within the matche clause that matches [k v], both k and v are not being matched against the upper k and v, but rather create fresh variables instead. I can work around the issue by writing the following: {code} (defn map-geto* [m k v] (matche [m] ([[[k' v'] . _]] (== k k') (== v v')) ([[_ . tail]] (map-geto* tail k v)))) (run* [q] (map-geto* (seq {:title "Blub" }) :title q)) {code} Is this intended behavior? |
David Nolen
made changes -
| Resolution | Completed [ 1 ] | |
| Status | Open [ 1 ] | Resolved [ 5 ] |