评论者: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) . . .) 形式,这正是我不希望在这个情况下看到的。
我实在不知道为什么这里不工作,而匹配测试案例中却工作了。