From 0ad7f0415bed1b83d050bc84fbeb1ef13f86649c Mon Sep 17 00:00:00 2001 From: davidnolen Date: Wed, 20 Nov 2024 07:48:15 -0800 Subject: [PATCH] * missing information from try/catch processing, we need to add `:local` `:catch` so that `analyze-symbol` can pick it up later * add test-try --- src/main/clojure/cljs/analyzer.cljc | 6 +++++- src/test/clojure/cljs/analyzer/spec_tests.clj | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/clojure/cljs/analyzer.cljc b/src/main/clojure/cljs/analyzer.cljc index 47bb73dc4..3b88875b7 100644 --- a/src/main/clojure/cljs/analyzer.cljc +++ b/src/main/clojure/cljs/analyzer.cljc @@ -1880,7 +1880,11 @@ (assoc locals e {:name e :line (get-line e env) - :column (get-col e env)}) + :column (get-col e env) + ;; :local is required for {:op :local ...} nodes + ;; but previously we had no way to figure this out + ;; by adding it here we can recover it later + :local :catch}) locals) catch (when cblock (disallowing-recur (analyze (assoc catchenv :locals locals) cblock))) diff --git a/src/test/clojure/cljs/analyzer/spec_tests.clj b/src/test/clojure/cljs/analyzer/spec_tests.clj index 4ea5f8d91..48f3930bf 100644 --- a/src/test/clojure/cljs/analyzer/spec_tests.clj +++ b/src/test/clojure/cljs/analyzer/spec_tests.clj @@ -249,7 +249,7 @@ (is (= :throw (:op node))) (is (s/valid? ::a/node node)))) -#_(deftest test-try +(deftest test-try (let [node (no-warn (analyze ns-env '(try 1 (catch :default e) (finally))))] (is (= :try (:op node))) (is (s/valid? ::a/node node))))