Skip to content

Commit 6bd816f

Browse files
mfikesswannodette
authored andcommitted
CLJS-1668: Self-host: Macro checking support
1 parent 63a4634 commit 6bd816f

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

src/main/cljs/cljs/spec.cljs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -299,20 +299,18 @@
299299
(apply f args)))
300300
(gobj/extend f))))
301301

302-
;(defn- macroexpand-check
303-
; [v args]
304-
; (let [specs (fn-specs v)]
305-
; (when-let [arg-spec (:args specs)]
306-
; (when (= ::invalid (conform arg-spec args))
307-
; (let [ed (assoc (explain-data* arg-spec [:args]
308-
; (if-let [name (spec-name arg-spec)] [name] []) [] args)
309-
; ::args args)]
310-
; (throw (js/Error.
311-
; (str
312-
; "Call to " (->sym v) " did not conform to spec:\n"
313-
; (with-out-str (explain-out ed))))))))))
314-
315-
302+
(defn- macroexpand-check
303+
[v args]
304+
(let [specs (fn-specs v)]
305+
(when-let [arg-spec (:args specs)]
306+
(when (= ::invalid (conform arg-spec args))
307+
(let [ed (assoc (explain-data* arg-spec [:args]
308+
(if-let [name (spec-name arg-spec)] [name] []) [] args)
309+
::args args)]
310+
(throw (js/Error.
311+
(str
312+
"Call to " (->sym v) " did not conform to spec:\n"
313+
(with-out-str (explain-out ed))))))))))
316314

317315
(defn- no-fn-specs
318316
[v specs]

src/main/clojure/cljs/analyzer.cljc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2375,10 +2375,12 @@
23752375
(if-not (nil? mac-var)
23762376
(#?@(:clj [binding [*ns* (create-ns *cljs-ns*)]]
23772377
:cljs [do])
2378-
(let [#?@(:clj [mchk (some-> (find-ns 'clojure.spec)
2378+
(let [mchk #?(:clj (some-> (find-ns 'clojure.spec)
23792379
(ns-resolve 'macroexpand-check))
2380-
_ (when mchk
2381-
(mchk mac-var (next form)))])
2380+
:cljs (and ^::no-resolve cljs.spec
2381+
^::no-resolve cljs.spec/macroexpand-check))
2382+
_ (when mchk
2383+
(mchk mac-var (next form)))
23822384
form' (try
23832385
(apply @mac-var form env (rest form))
23842386
#?(:clj (catch ArityException e

0 commit comments

Comments
 (0)