Skip to content

Commit 72cc61d

Browse files
dynj: fix handling of body in defn-dynj
While `declare-dynj` is implemented in terms of `defn-dynj`, it only worked "by accident".
1 parent 03abef9 commit 72cc61d

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/active/clojure/dynj.clj

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,15 @@
5252

5353
(defmacro defn-dynj
5454
"Declares `name` as a dynamic injection point, to be bound to an
55-
implementation/value later via [[binding]], and adds a default
56-
implementation. Typically you would throw a helpful exception in the
57-
body."
55+
implementation/value later via [[binding]], and adds a default implementation.
56+
Typically you would throw a helpful exception in `body`."
5857
[name params & body]
5958
(let [[docstring params body]
6059
(if (string? params)
6160
[params (first body) (rest body)]
6261
[nil params body])]
6362

64-
`(do (defn ~name [~@params] ~body)
63+
`(do (defn ~name [~@params] ~@body)
6564
(alter-meta! (var ~name) assoc
6665
:dynamic true
6766
::dynj true

test/active/clojure/dynj_test.clj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,9 @@
2525
(sut/bound-fn* (fn [v]
2626
(foo v))))]
2727
(t/is (= 8 (f 4)))))
28+
29+
(sut/defn-dynj bar [arg]
30+
(* 3 arg))
31+
32+
(t/deftest defn-dynj-default-implementation-test
33+
(t/is (= 9 (bar 3))))

0 commit comments

Comments
 (0)