Details
-
Type:
Defect
-
Status:
Resolved
-
Priority:
Minor
-
Resolution: Completed
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Environment:Hidejava version "1.7.0_07"
OpenJDK Runtime Environment (IcedTea7 2.3.2) (Gentoo build 1.7.0_07-b30)
OpenJDK 64-Bit Server VM (build 23.2-b09, mixed mode)
org.clojure/clojure "1.5.0-alpha4"
org.clojure/core.logic "0.8-alpha3"Showjava version "1.7.0_07" OpenJDK Runtime Environment (IcedTea7 2.3.2) (Gentoo build 1.7.0_07-b30) OpenJDK 64-Bit Server VM (build 23.2-b09, mixed mode) org.clojure/clojure "1.5.0-alpha4" org.clojure/core.logic "0.8-alpha3"
Description
The fd comparison relations always succeed when used with strings or a string and an integer:
user> (run* [q] (<=fd "foo" "bar")) (_.0) user> (run* [q] (<=fd "foo" 1)) (_.0) user> (run* [q] (<=fd 1 "bar")) (_.0)
IMHO, they should always fail if one argument is not a integer.
Furthermore, you get an exception when comparing integers and the larger integer is given first.
user> (run* [q] (<=fd 1 2)) (_.0) ;; That's correct, but... user> (run* [q] (<=fd 2 1)) IllegalArgumentException No implementation of method: :member? of protocol: #'clojure.core.logic/ISet found for class: nil clojure.core/-cache-protocol-fn (core_deftype.clj:533)
I'd expect that comparisons of two integers should always work. You can circumvent this issue by unifying the numbers with some logic variables first, but is that really needed?
user> (run* [q] (fresh [a b] (== a 1) (== b 2) (<=fd a b))) (_.0) user> (run* [q] (fresh [a b] (== a 1) (== b 2) (<=fd b a))) ()
The first issue cannot be circumvented using this approach, though.
user> (run* [q] (fresh [a b] (== a "foo") (== b 2) (<=fd b a))) (_.0) user> (run* [q] (fresh [a b] (== a "foo") (== b 2) (<=fd a b))) (_.0) user> (run* [q] (fresh [a b] (== a "foo") (== b "bar") (<=fd a b))) (_.0) user> (run* [q] (fresh [a b] (== a "foo") (== b "bar") (<=fd b a))) (_.0)
Thanks for the update!