From fab241f6ac04cf8516150a7ccbe1b0e99b8323f8 Mon Sep 17 00:00:00 2001 From: Roman Volosovskyi Date: Sat, 27 Mar 2021 12:05:23 +0200 Subject: [PATCH] Pevent incorrect usage of fx/defn inside fx/merge Signed-off-by: Andrea Maria Piana --- src/status_im/utils/fx.clj | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/status_im/utils/fx.clj b/src/status_im/utils/fx.clj index ef3f7a976a..76fdbdbc84 100644 --- a/src/status_im/utils/fx.clj +++ b/src/status_im/utils/fx.clj @@ -52,8 +52,18 @@ ([cofx# ~@args] (if (and (map? cofx#) (not (nil? (:db cofx#)))) - (let [~cofx cofx#] - ~@fdecl) + (let [res# (let [~cofx cofx#] ~@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)))))) ~@(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))))))