Details
-
Type:
Defect
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Declined
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Patch:Code and Test
Description
Unification fails for partial-map when there is a partial match on a sub-map.
A failing test case:
(is (= '[#clojure.core.logic.PMap{:a {:b 2}}]
(run* [q]
(fresh [pm x]
(== (partial-map {:a {:b x}}) pm)
(== {:a {:b 2 :c 3}} pm)
(== q pm)))))
As mentioned by Kevin Lynagh, this can be achieved using walk-term, and I agree the behaviour is better off being explicit.
(defn ->pmap [x] (if (map? x) (l/partial-map x) x)) (l/unifier target (->pmap (l/walk-term my-map ->pmap)))(defn ->pmap [x] (if (map? x) (l/partial-map x) x)) (l/unifier target (->pmap (l/walk-term my-map ->pmap)))