<< Back to previous view

[LOGIC-67] match(e/a) in ClojureScript always creates free var Created: 14/Nov/12  Updated: 28/Jul/13  Resolved: 14/Nov/12

Status: Closed
Project: core.logic
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Thomas Karolski Assignee: David Nolen
Resolution: Completed Votes: 0
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?



 Comments   
Comment by David Nolen [ 14/Nov/12 5:52 PM ]

fixed, http://github.com/clojure/core.logic/commit/fff0033b288a2ff80ce3bc672e1daabfa16e555b

Generated at Sun Apr 20 11:02:45 CDT 2014 using JIRA 4.4#649-r158309.