Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spec-tools/merge broken when one spec is a symbol #201

Closed
slipset opened this issue Jan 4, 2020 · 1 comment
Closed

spec-tools/merge broken when one spec is a symbol #201

slipset opened this issue Jan 4, 2020 · 1 comment
Labels
Milestone

Comments

@slipset
Copy link
Contributor

slipset commented Jan 4, 2020

(s/def ::foo string?)
(s/def ::bar string?)

(s/def ::qix (s/keys :req-un [::foo]))
(s/def ::qux (s/keys :req-un [::bar]))

(spec-tools/merge ::qix ::qux) ;; works as expected

(def qix ::qix)

(spec-tools/merge qix ::qux) ;; broken

By changing spec-tools.impl/resolve-form to

   (defn resolve-form [env pred]
     (let [cljs? (in-cljs? env)
           res (if cljs? (partial cljs-resolve env) clojure.core/resolve)]
       (->> pred
            (walk/postwalk
             (fn [x]
               (if (symbol? x)
                 (let [v (eval x)]
                   (if (s/get-spec (eval x))
                     (eval x)
                     (->> x res ->sym)))
                 x)))
            (unfn cljs?)))))

it seems to work, but, this seems rather ugly to me, so I'd rather not submit a PR with this as a patch.

@miikka
Copy link
Contributor

miikka commented May 5, 2020

Fixed in 0.10.2.

@miikka miikka closed this as completed May 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants