大家好,我来报告我认为是本周第二次的spec仪表件上的问题。
如果这已被报告为错误,我深表歉意,但基本上我无法理解/预料到最后一次调用会触发错误 - ::id-map spec最终并不需要在::other上进行检查。
(ns repro-spec.test
(:require [clojure.spec.alpha :as s]
[clojure.spec.test.alpha :as st]))
(s/def ::impl any?)
(s/def ::id string?)
(s/def ::other number?)
(s/def ::id-map (s/keys :req [::id]))
(s/fdef delete-impl
:args (s/cat :impl ::impl
:id-map ::id-map))
(defn delete-impl [_ id-map]
(println (str "This deletes " (::id id-map)))
id-map)
(st/instrument)
(delete-impl {} {::id "test"})
;; prints "This deletes test"
(delete-impl {} {::id "test" ::other "ignore me"})
;; Execution error - invalid arguments to repro-spec.test/delete-impl at (REPL:27).
;; "ignore me" - failed: number? at: [:id-map :repro-spec.test/other] spec: :repro-spec.test/other
是我做错了什么吗?