robertluo/fun-map

when a `fw` or `fnk` ref itself, `StackOverflowError` occurred.

Closed this issue · 1 comments

(def fm (fun-map {:a   1
                  :b   2
                  :sum (fw {:keys [a b sum]}
                           (+ a b sum))}))

(:sum fm)

;; => StackOverflowError   java.lang.ClassLoader.findLoadedClass (ClassLoader.java:1273)
(def fm (fun-map {:a   1
                  :b   2
                  :sum (fnk [a b sum]
                            (+ a b sum))}))

(:sum fm)

;; => StackOverflowError   clojure.lang.PersistentArrayMap.assoc (PersistentArrayMap.java:192)

As showed above,the FunctionWrapper of :sum ref to itself。

fun-map does not check cyclic dependency, so it is the user's responsibility to make sure not referring that.