评论者: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) ...) 形式,这正是我不希望在这个情况下看到的东西。
我真心不知道为什么这里不工作,而match测试用例却可以。