评论者:joeosborn
HEAD 中的这个测试用例也有同样的异常(很抱歉所有的这些事实)
`
(defrel thing- [Thing])
(defrel type- [Thing] [Type])
(fact thing- [0])
(fact thing- [1])
(fact thing- [2])
(fact type- [0] [:player])
(fact type- [1] [:dragon])
(fact type- [2] [:pig])
(defn type-enum [t] [:type t])
(defna drawable- [Key]
([[Thing]] (thing- [Thing]) (fresh [Type] (type- [Thing] [Type]) (drawable- [Type])))
([[(type-enum :player)]] succeed)
([[(type-enum :dragon)]] succeed))
(deftest do-fns-work
(is (= (run* [q] (drawable- [q])) '(0 1))))
`
现在我看看,我可能期待的返回值格式错误,但关键是连到这里都没到达。
使用 REPL,我检查了 (defna drawable- . . .) 的展开情况(稍微整理了一下)
`
(def drawable- (clojure.core/fn ([Key]
(clojure.core.logic/conda
((clojure.core.logic/fresh [Thing] (clojure.core.logic/== [Thing] Key) (thing- [Thing]) (fresh [Type] (type- [Thing] [Type]) (drawable- [Type]))))
((clojure.core.logic/fresh [type-enum]
(clojure.core.logic/== [(type-enum :player)] Key) succeed))
((clojure.core.logic/fresh [type-enum]
(clojure.core.logic/== [(type-enum :dragon)] Key) succeed))))))
`
注意这里的 (clojure.core.logic/fresh (link: type-enum) . . .) 表达式,这正是我不希望在这个情况下看到的。
我不太确定为什么这在这里不工作,而在 matche 测试用例中工作。