Pevent incorrect usage of fx/defn inside fx/merge

Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
This commit is contained in:
Roman Volosovskyi 2021-03-27 12:05:23 +02:00 committed by Andrea Maria Piana
parent 594c83013c
commit fab241f6ac
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
1 changed files with 12 additions and 2 deletions

View File

@ -52,8 +52,18 @@
([cofx# ~@args] ([cofx# ~@args]
(if (and (map? cofx#) (if (and (map? cofx#)
(not (nil? (:db cofx#)))) (not (nil? (:db cofx#))))
(let [~cofx cofx#] (let [res# (let [~cofx cofx#] ~@fdecl)]
~@fdecl) (when-not (nil? res#)
(aset res#
"cljs$core$ILookup$_lookup$arity$2"
(fn [foo# k#]
(clojure.core/this-as
m#
(when (and (map? k#)
(contains? k# :db))
(throw (js/Error. (str "fx/defn's result is used as fx producing function in " ~name))))
(get m# k# nil)))))
res#)
(throw (js/Error. (str "fx/defn expects a map of cofx as first argument got " cofx# " in function " ~name)))))) (throw (js/Error. (str "fx/defn expects a map of cofx as first argument got " cofx# " in function " ~name))))))
~@(register-events events interceptors (with-meta name m) argsyms)) ~@(register-events events interceptors (with-meta name m) argsyms))
(throw (Exception. (str "fx/defn expects a vector of keyword as value for :events key in attr-map in function " name)))))) (throw (Exception. (str "fx/defn expects a vector of keyword as value for :events key in attr-map in function " name))))))