Browse files

LOGIC-119: quick fix to ensure disunify on maps can deal with non-map…

… other.
  • Loading branch information...
1 parent 11d2dd5 commit 8af0f45f8d1cb515ec7a00e5acd751562a31bb37 @namin namin committed Mar 12, 2013
View
2 src/main/clojure/clojure/core/logic.clj
@@ -2408,7 +2408,7 @@
clojure.lang.IPersistentMap
(disunify-terms [u v s cs]
- (if (= (count u) (count v))
+ (if (and (map? v) (= (count u) (count v)))
(loop [ks (seq (keys u)) cs cs]
(if ks
(let [kf (first ks)
View
19 src/test/clojure/clojure/core/logic/nominal/tests.clj
@@ -502,3 +502,22 @@
(nom/hash a x)
(== q [x a]))))
'(([_0 a_1] :- a_1#_0)))))
+
+(deftest test-logic-119-tie-disequality-1
+ (is (= (run* [q]
+ (nom/fresh [a]
+ (!= (nom/tie a a) 'foo)))
+ '(_0)))
+ (is (= (run* [q]
+ (nom/fresh [a]
+ (!= (nom/tie a a) (nom/tie a a))))
+ '()))
+ (is (= (run* [q]
+ (nom/fresh [a b]
+ (!= (nom/tie a a) (nom/tie a b))))
+ '(_0)))
+ (comment ;; this one will be tricky to get right.
+ (is (= (run* [q]
+ (nom/fresh [a b]
+ (!= (nom/tie a a) (nom/tie b b))))
+ '()))))
View
5 src/test/clojure/clojure/core/logic/tests.clj
@@ -1042,6 +1042,11 @@
(== x [1 w])
(== y [2 z])))
'(_0))))
+
+(deftest test-logic-119-disequality-1
+ (is (= (run* [q]
+ (!= {1 2 3 4} 'foo))
+ '(_0))))
;; -----------------------------------------------------------------------------
;; tabled

0 comments on commit 8af0f45

Please sign in to comment.