diff --git a/src/main/clojure/cljs/analyzer.cljc b/src/main/clojure/cljs/analyzer.cljc index 4e52de69f..f1182116f 100644 --- a/src/main/clojure/cljs/analyzer.cljc +++ b/src/main/clojure/cljs/analyzer.cljc @@ -2143,6 +2143,7 @@ {:line line :column column}) param {:op :binding :name name + :form name :line line :column column :tag tag @@ -2205,8 +2206,10 @@ shadow (or (handle-symbol-local name (get locals name)) (get-in env [:js-globals name])) fn-scope (:fn-scope env) - name-var {:name name - :op :binding + name-var {:op :binding + :env env + :form name + :name name :local :fn :info {:fn-self-name true :fn-scope fn-scope @@ -2326,8 +2329,10 @@ (let [ret-tag (-> n meta :tag) fexpr (no-warn (analyze env (n->fexpr n))) be (cond-> - {:name n - :op :binding + {:op :binding + :name n + :form n + :env env :fn-var true :line (get-line n env) :column (get-col n env) @@ -2416,7 +2421,8 @@ col (get-col name env) shadow (or (handle-symbol-local name (get-in env [:locals name])) (get-in env [:js-globals name])) - be {:name name + be {:op :binding + :name name :form name :line line :column col @@ -2426,7 +2432,6 @@ :shadow shadow ;; Give let* bindings same shape as var so ;; they get routed correctly in the compiler - :op :binding :env {:line line :column col} :info {:name name :shadow shadow} diff --git a/src/test/clojure/cljs/analyzer/spec_tests.clj b/src/test/clojure/cljs/analyzer/spec_tests.clj index 44ab18ef4..95bcd6d53 100644 --- a/src/test/clojure/cljs/analyzer/spec_tests.clj +++ b/src/test/clojure/cljs/analyzer/spec_tests.clj @@ -33,8 +33,19 @@ (deftest test-def (is (s/valid? ::a/node (no-warn (analyze ns-env '(def x))))) (is (s/valid? ::a/node (no-warn (analyze ns-env '(def x 1))))) + (is (s/valid? ::a/node (no-warn (analyze ns-env '(def x (fn [])))))) + (is (s/valid? ::a/node (no-warn (analyze ns-env '(def x (fn [y] y))))))) + +(deftest test-fn (is (s/valid? ::a/node (no-warn (analyze ns-env '(fn []))))) - (is (s/valid? ::a/node (no-warn (analyze ns-env '(fn [] 1)))))) + (is (s/valid? ::a/node (no-warn (analyze ns-env '(fn [] 1))))) + (is (s/valid? ::a/node (no-warn (analyze ns-env '(fn [x]))))) + (is (s/valid? ::a/node (no-warn (analyze ns-env '(fn [x] 1)))))) + +(deftest test-defn + (is (s/valid? ::a/node (no-warn (analyze ns-env '(defn x []))))) + (is (s/valid? ::a/node (no-warn (analyze ns-env '(defn x [] 1))))) + (is (s/valid? ::a/node (no-warn (analyze ns-env '(defn x [y] y)))))) (deftest test-new (is (s/valid? ::a/node (no-warn (analyze ns-env '(new String))))) @@ -49,10 +60,4 @@ (s/valid? ::a/node (no-warn (analyze ns-env '(case x 1 :foo 2 :bar)))) (s/explain ::a/node (no-warn (analyze ns-env '(case x 1 :foo 2 :bar)))) - (s/valid? ::a/node (no-warn (analyze ns-env '(def x (fn []))))) - (s/explain ::a/node (no-warn (analyze ns-env '(def x (fn []))))) - - (s/valid? ::a/node (no-warn (analyze ns-env '(fn [x])))) - (s/valid? ::a/node (no-warn (analyze ns-env '(fn [x] 1)))) - )