ClojureScript

When calling cljs.spec/valid?, subsequent predicates of cljs.spec/and are evaluated even when early predicate is unsatisfied

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:

Description

Affects 1.9.456 and 1.9.473.

The problem is that subsequent predicates of cljs.spec/and are evaluated even when an early predicate is unsatisfied when calling cljs.spec/valid?.

See https://github.com/henriklundahl/minimal-cljs-spec-problem for a minimal example demonstrating the problem.

Activity

Hide
David Nolen added a comment -

Please do not link outside. Minimal examples need to be in the ticket. This means no project. Just code demonstrating the problem. Thanks.

Show
David Nolen added a comment - Please do not link outside. Minimal examples need to be in the ticket. This means no project. Just code demonstrating the problem. Thanks.
Hide
Henrik Lundahl added a comment -

Since I'm not allowed to edit the description I'll just add the details here.

The following code renders an exception:

(ns asdf
(:require [clojure.spec :as s]))

(defn pred-1? [s]
(> (count s) 100))

(defn pred-2? [s]
(> (count s) 100))

(defn pred-3? [s]
(> (count s) 100))

(s/valid? (s/and string? pred-1? pred-2? pred-3?) "a")

The exception is something like:

Uncaught Error: No protocol method ICounted.-count defined for type cljs.core/Keyword: :cljs.spec/invalid

This works in both Clojure 1.9.0-alpha14 and ClojureScript 1.9.293. It does not work in neither ClojureScript 1.9.456 nor ClojureScript 1.9.473.

Show
Henrik Lundahl added a comment - Since I'm not allowed to edit the description I'll just add the details here. The following code renders an exception:
(ns asdf (:require [clojure.spec :as s])) (defn pred-1? [s] (> (count s) 100)) (defn pred-2? [s] (> (count s) 100)) (defn pred-3? [s] (> (count s) 100)) (s/valid? (s/and string? pred-1? pred-2? pred-3?) "a")
The exception is something like:
Uncaught Error: No protocol method ICounted.-count defined for type cljs.core/Keyword: :cljs.spec/invalid
This works in both Clojure 1.9.0-alpha14 and ClojureScript 1.9.293. It does not work in neither ClojureScript 1.9.456 nor ClojureScript 1.9.473.
Hide
Henrik Lundahl added a comment -

Thanks!

Show
Henrik Lundahl added a comment - Thanks!

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: