评论者: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测试案例中工作。