Check should specize function specs before checking

Description

This code works fine in 1.9.0-alpha12:

(defn f [x] (+ x 1)) (s/def f (s/fspec :args (s/cat :x number?) :ret number?)) (stest/check `f)

But if we factor the fspec out into its own keyword:

(defn f [x] (+ x 1)) (s/def ::inc (s/fspec :args (s/cat :x number?) :ret number?)) (s/def f ::inc) (stest/check `f)

The check fails with the exception:

({:failure #error { :cause "No :args spec" :data #:clojure.spec{:failure :no-args-spec} :via [{:type clojure.lang.ExceptionInfo :message "No :args spec" :data #:clojure.spec{:failure :no-args-spec} :at [...]}] :trace [...]}, :sym user/f, :spec :user/inc})

The check function doesn't seem to be resolving ::inc, when presumably it should.

Patch: clj-2024-2.patch

Environment

None

Attachments

2
  • 28 Oct 2016, 02:43 PM
  • 22 Sep 2016, 09:40 PM

Activity

Show:

Alex MillerOctober 28, 2016 at 2:43 PM

Added new patch that uses `spec` instead of private `specize` function.

Alex MillerOctober 28, 2016 at 2:23 PM

fspec is not the problem as far as I can tell - it is already making specs of its args.

The problem is that f is registered as an alias of ::inc. I don't think you want to resolve that at registration time (as ::inc might not exist yet).

The problem as far as I understand it is that at the time of use (by check), f is not resolved to it's final spec and that's what the patch does.

Rich HickeyOctober 28, 2016 at 1:44 PM

this should be fixed in fspec, not its use by test

Completed

Details

Assignee

Reporter

Labels

Approval

Ok

Patch

Code

Priority

Affects versions

Fix versions

Created September 19, 2016 at 5:50 PM
Updated October 28, 2016 at 8:24 PM
Resolved October 28, 2016 at 8:24 PM

Flag notifications