<< Back to previous view

[LOGIC-74] Bug in conde (ClojureScript) Created: 26/Nov/12  Updated: 28/Jul/13  Resolved: 17/Mar/13

Status: Closed
Project: core.logic
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Kevin De Valck Assignee: David Nolen
Resolution: Declined Votes: 0
Labels: bug

[org.clojure/clojure "1.4.0"]
[org.clojure/core.logic "0.8.0-beta2"]


While working on a project I found a somewhat strange behaviour. I reworked the problem in some simple predicate. Let's take this predicate foobad.

(defn foobad 
  (l/project [?bar]
    (l/fresh [?var]
        [(l/== true (instance? js/Array ?bar))
          (membero ?var (seq ?bar))]))))

When running (l/run* [?f] (foobad 0)) it produces this error:

#<Error: No protocol method ISeqable.-seq defined for type number: 0>

Because 0 is not an instance of Array it should not be entering that conde clause where it tries (seq 0).

With this workaround we get a normal behaviour:

(defn foo 
  (l/project [?bar]
    (l/fresh [?var]
        [(l/== true (instance? js/Array ?bar)) 
         (fresh [?s]
          (l/== ?s (seq ?bar))
          (membero ?var ?s))]))))

Running (l/run* [?f] (foo 0)) gives us (), which is what we expect.
While 0 is clearly not an instance of Array that conde clause is still executed resulting in previous error.

Comment by David Nolen [ 28/Dec/12 12:49 AM ]

I'm assuming this is referring the ClojureScript version of core.logic?

Comment by David Nolen [ 17/Mar/13 7:00 PM ]

This is not a bug. Goals do not delay evaluation in this way.

Generated at Sat Jan 20 09:41:11 CST 2018 using JIRA 4.4#649-r158309.