Setting finite domain on more than two lvars using domain fn throws UnsupportedOperationException


  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Declined
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Environment:
    Clojure 1.4.0 , core.logic 0.8.0-beta3


When specifying domains on more than two lvars core.logic 0.8.0-beta3 throws an UnsupportedOperationException. Here's an example:

(run* [q]
    (fresh [x y z]
        (infd x y z (domain 1 2 3))
  	    (<fd x y)
  	    (<fd y z)
        (== q [x y z])))
  • 0.8.0-beta2: nil.
  • 0.8.0-beta3: UnsupportedOperationException count not supported on this type: FiniteDomain clojure.lang.RT.countFrom (
  • 0.8.0-beta4-SNAPSHOT (739ec7e): ([1 2 3]) (correct result)

I've checked and commit 07f2f6a introduced the fix, so this is possibly related to LOGIC-77.

When trying to isolate the bug I found that:

  • Using `(interval 1 3)` instead of `(domain 1 2 3)` works.
  • Using two fresh variables instead of three works:
(run* [q]
      (fresh [x y]
	      (infd x y (domain 1 2))
  	    (<fd x y)
        (== q [x y])))
;=> ([1 2])

Here's a test that checks the behavior. The test works in the latest version but fails in all commits before 07f2f6a.

(deftest test-domfd-three-lvars []
  (is (= (run* [q]
           (fresh [x y z]
           (infd x y z (domain 1 2 3))
           (<fd x y)
           (<fd y z)
           (== q [x y z])))
         '([1 2 3]))))



Vote (0)
Watch (1)


  • Created: