Share your thoughts in the 2021 Clojure Community Survey!

Welcome! Please see the About page for a little more info on how this works.

+1 vote
in Clojure by
closed by

In a project, I required + aliased clojure.alpha.spec like this:

(ns example.core
    (:require [clojure.alpha.spec :as spec]))

Then I tried to define a simple spec like

(spec/def ::example-spec #(not (neg? %)))

Compiling gave the error that namespace s was undefined.

I believe this came down to a typo in clojure.alpha.spec/def. In file spec-alpha2/src/main/clojure/clojure/alpha/spec.clj, line 456, there is a backquoted s/spec but the alias at the top of the file is to sa. Here's line 456:

    (#{'fn 'fn* `c/fn} op) `(s/spec ~explicated-form)

After changing the line to

(#{'fn 'fn* `c/fn} op) `(sa/spec ~explicated-form)

my spec/def works successfully.

closed with the note: fixed

1 Answer

0 votes
by
selected by
 
Best answer

Yep, this is definitely wrong. The suggested fix is not correct though - the sa alias is referring to the old spec.alpha (not this alpha.spec) and is used to be able to do error reporting in a way that matches spec 1. Just need to pull the alias entirely. Fixed in master.

...