Welcome! Please see the About page for a little more info on how this works.

0 votes
in core.logic by

Some pattern-matching expressions that should work fail, because the dynamic variable **locals** is not bound. For example:

(matche
(link: x)
((link: '(~a))))

gives an error during macroexpansion, that contains? cannot be applied to an unbound variable:

CompilerException java.lang.IllegalArgumentException: contains? not supported on type: clojure.lang.Var$Unbound

(The referenced call to contains? is in lvar-sym?, where we check whether a variable that appears within a pattern is already a local variable.)

I believe this is what is happening:

  1. At two places in p->term, we call map to apply p->term recursively to subpatterns: (map #(p->term % vars quoted) p), for example.
  2. map returns a LazySeq.
  3. By the time the elements of the LazySeq are actually forced (this happens during macro expansion), the dynamic locals variable is no longer bound.

One solution might be to wrap a (doall ...) around the two calls to map mentioned above (lines 1523 and 1529 of logic.clj).

2 Answers

0 votes
by

Comment made by: alexlew

I apologize for the poor formatting above! I am new to JIRA (and can't find an Edit button).

0 votes
by
Reference: https://clojure.atlassian.net/browse/LOGIC-187 (reported by alex+import)
...