Skip to content

Commit 377c341

Browse files
committed
Filter non-LocalBinding values from &env
This has no impact on normal usage, but allows for linting of the library with eastwood (since eastwood uses tools.analyzer.jvm, which is incompatible with macros that use Clojure's default &env).
1 parent 34553d3 commit 377c341

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/debugger/core.clj

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@
66
safe-find-var
77
no-sources-found]]
88
[debugger.commands :refer [print-short-source print-trace]]
9-
[debugger.repl :refer [prompt-fn read-fn eval-fn caught-fn]]))
9+
[debugger.repl :refer [prompt-fn read-fn eval-fn caught-fn]])
10+
(:import [clojure.lang Compiler$LocalBinding]))
11+
12+
(defn- sanitize-env
13+
[env]
14+
(into {} (for [[sym bind] env
15+
:when (instance? Compiler$LocalBinding bind)]
16+
[`(quote ~sym) (.sym bind)])))
1017

1118
(defmacro dbg
1219
[x]
@@ -16,7 +23,7 @@
1623
x#)))
1724

1825
(defmacro break [& body]
19-
(let [env (into {} (map (fn [[sym bind]] [`(quote ~sym) (.sym bind)]) &env))
26+
(let [env (sanitize-env &env)
2027
break-line (:line (meta &form))]
2128
`(let [trace# (-> (Throwable.) .getStackTrace seq)
2229
outer-fn-symbol# (-> trace# first .getClassName demunge deanonimize-name symbol)
@@ -65,7 +72,7 @@
6572

6673

6774
(defmacro break-catch [& body]
68-
(let [env (into {} (map (fn [[sym bind]] [`(quote ~sym) (.sym bind)]) &env))
75+
(let [env (sanitize-env &env)
6976
break-line (:line (meta &form))]
7077
`(try
7178
(do ~@body)

0 commit comments

Comments
 (0)