Certain functions that expect an integer argument and are not spec'd by Babel get caught by the :illegal-arg-must-be-int-seq error in our error_dictionary.clj. The message for this is misleading in cases where a sequence is not passed.
To reproduce/test:
- Since
(even?) and (odd?) are currently underspec'd, passing a double to them instead of an int will produce these errors:
babel.middleware=> (odd? 2.4)
Expected an integer number, but a sequence 2.4 was given instead.
- Entirely removing the spec for these functions also produces the same error for any non-integer argument.
Using a spec'd predicate in a higher-level spec seemingly "bypasses" the specs on the predicate function due to being evaluated differently from user code. This is also an unavoidable case, i.e. a cause for why these messages need to be improved even if the specs are fixed:
In corefns.clj:
(s/fdef clojure.core/even?
:args :babel.args/one-number)
(stest/instrument `clojure.core/even?)
(defn x [n] n)
(s/fdef x :args (s/cat :number even?))
(stest/instrument `x)
babel.middleware=> (corefns.corefns/x :a)
Expected an integer number, but a sequence :a was given instead.
TODO: Find examples of the other one:
{:key :illegal-arg-must-be-int-lazy
:class "IllegalArgumentException"
:match (beginandend #"Argument must be an integer: clojure\.lang\.LazySeq(.*)")
:fn (fn [matches] (str "Expected an integer number, but a sequence was given instead.\n"))}
Certain functions that expect an integer argument and are not spec'd by Babel get caught by the
:illegal-arg-must-be-int-seqerror in ourerror_dictionary.clj. The message for this is misleading in cases where a sequence is not passed.To reproduce/test:
(even?)and(odd?)are currently underspec'd, passing a double to them instead of an int will produce these errors:Using a spec'd predicate in a higher-level spec seemingly "bypasses" the specs on the predicate function due to being evaluated differently from user code. This is also an unavoidable case, i.e. a cause for why these messages need to be improved even if the specs are fixed:
In
corefns.clj:TODO: Find examples of the other one:
{:key :illegal-arg-must-be-int-lazy :class "IllegalArgumentException" :match (beginandend #"Argument must be an integer: clojure\.lang\.LazySeq(.*)") :fn (fn [matches] (str "Expected an integer number, but a sequence was given instead.\n"))}