Some pattern-matching expressions that should work fail, because the dynamic variable `locals` is not bound. For example:
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).
I am using Clojure 1.9.0, core.logic 0.8.11, on macOS 10.14.