Skip to content

Commit b5d543c

Browse files
committed
Fix instrumentation on forms like (-> 1 inc inc) "without wrapping parens
1 parent 9df4492 commit b5d543c

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

src/main/clojure/cljs/analyzer.cljc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2281,7 +2281,7 @@ x (not (contains? ret :info)))
22812281
:type type
22822282
:form form
22832283
:recurs recurs
2284-
:cljs.storm/coord (-> form meta :cljs.storm/coord)}
2284+
:cljs.storm/coord (storm-utils/coord-of form)}
22852285
(if (some? expr)
22862286
{:body (assoc expr :body? true)
22872287
:children [:params :body]}
@@ -2345,7 +2345,7 @@ x (not (contains? ret :info)))
23452345
skip-expr-instrumentation? (or (:cljs.storm/skip-expr-instrumentation? form-meta)
23462346
(:cljs.storm/skip-expr-instrumentation? (meta name)))
23472347
fn-trace-name (:cljs.storm/fn-trace-name form-meta)
2348-
form-coord (-> form meta :cljs.storm/coord)
2348+
form-coord (storm-utils/coord-of form)
23492349
env (cond-> env
23502350
true (assoc :enclosing-context :fn)
23512351
true (assoc :cljs.storm/wrapping-fn-coord form-coord)
@@ -2532,7 +2532,7 @@ x (not (contains? ret :info)))
25322532
be {:op :binding
25332533
:name name
25342534
:form name
2535-
:cljs.storm/coord (-> name meta :cljs.storm/coord)
2535+
:cljs.storm/coord (storm-utils/coord-of name)
25362536
:line line
25372537
:column col
25382538
:init init-expr
@@ -4149,7 +4149,8 @@ x (not (contains? ret :info)))
41494149
(do
41504150
(register-constant! env sym)
41514151
(analyze-wrap-meta {:op :const :val sym :env env :form sym :tag 'cljs.core/Symbol}))
4152-
(let [{:keys [line column cljs.storm/coord]} (meta sym)
4152+
(let [{:keys [line column]} (meta sym)
4153+
coord (storm-utils/coord-of sym)
41534154
env (if-not (nil? line)
41544155
(assoc env :line line)
41554156
env)
@@ -4661,7 +4662,7 @@ x (not (contains? ret :info)))
46614662
skip-ns? (storm-emitter/skip-instrumentation? (get-in env [:ns :name]))
46624663
form (cond-> form
46634664
(and top-level-form? (not skip-ns?)) (storm-utils/tag-form-recursively :cljs.storm/coord))
4664-
{:keys [cljs.storm/coord]} (meta form)
4665+
coord (storm-utils/coord-of form)
46654666
env (cond-> env
46664667
top-level-form? (assoc :cljs.storm/form-id (hash form)
46674668
:cljs.storm/form-emitted-coords-set (atom #{}))

src/main/clojure/cljs/storm/utils.cljc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@
44
#?(:clj (:import [java.nio.file Files]
55
[java.nio.file.attribute FileTime])))
66

7+
(defn coord-of [form]
8+
(if-let [coord (-> form meta :cljs.storm/coord)]
9+
coord
10+
(when (and form
11+
(seq? form)
12+
(pos? (count form)))
13+
;; If the form is a list and has no coord, maybe it was
14+
;; destroyed by a macro. Try guessing the coord by looking at
15+
;; the first element. This fixes `->`, for instance.
16+
17+
(-> form first meta :cljs.storm/coord))))
18+
719
(defn merge-meta
820

921
"Non-throwing version of (vary-meta obj merge metamap-1 metamap-2 ...).

0 commit comments

Comments
 (0)