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:
- At two places in
p->term, we call
map to apply p->term recursively to subpatterns:
(map #(p->term % vars quoted) p), for example.
map returns a LazySeq.
- 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).