core.logic

match(e/a) in ClojureScript always creates free var

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major 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?

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: