core.logic

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

Details

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

Description

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 (RT.java:545)
  • 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]))))

Activity

Hide
David Nolen added a comment -

So is there a bug in master or not? To keep tracking issues simpler, if the bug does not exist in master please don't open a ticket.

Show
David Nolen added a comment - So is there a bug in master or not? To keep tracking issues simpler, if the bug does not exist in master please don't open a ticket.
Hide
Frederik De Bleser added a comment -

The issue is fixed in master.

I still wanted to report it since it seems to somehow relate to LOGIC-77 – maybe I should just have added a comment there.

Sorry for the confusion.

Show
Frederik De Bleser added a comment - The issue is fixed in master. I still wanted to report it since it seems to somehow relate to LOGIC-77 – maybe I should just have added a comment there. Sorry for the confusion.
Hide
David Nolen added a comment -

Not relevant to master.

Show
David Nolen added a comment - Not relevant to master.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: