Skip to content

Commit

Permalink
* some :binding node missing :env and :form
Browse files Browse the repository at this point in the history
* def, fn, defn tests
  • Loading branch information
swannodette committed Oct 25, 2024
1 parent 2bd179a commit 83dadc9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
17 changes: 11 additions & 6 deletions src/main/clojure/cljs/analyzer.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -2143,6 +2143,7 @@
{:line line :column column})
param {:op :binding
:name name
:form name
:line line
:column column
:tag tag
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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}
Expand Down
19 changes: 12 additions & 7 deletions src/test/clojure/cljs/analyzer/spec_tests.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)))))
Expand All @@ -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))))

)

0 comments on commit 83dadc9

Please sign in to comment.