From 4eb44ae01b0f4342ca4707d2a93ff85357a982ae Mon Sep 17 00:00:00 2001 From: Enzzo Cavallo Date: Fri, 29 Nov 2024 23:41:59 -0300 Subject: [PATCH] cljs-2292 refer-clojure rename should also exclude --- src/main/clojure/cljs/analyzer.cljc | 6 +++++- src/test/cljs/cljs/ns_test.cljs | 4 ++++ src/test/clojure/cljs/analyzer_tests.clj | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/clojure/cljs/analyzer.cljc b/src/main/clojure/cljs/analyzer.cljc index 887ae349a..8c61c4586 100644 --- a/src/main/clojure/cljs/analyzer.cljc +++ b/src/main/clojure/cljs/analyzer.cljc @@ -2907,7 +2907,7 @@ (parse-ns-error-msg spec "Each of :as and :refer options may only be specified once in :require / :require-macros")))))) -(defn parse-ns-excludes [env args] +(defn- parse-ns-excludes-impl [env args] (reduce (fn [s [k & filters]] (if (= k :refer-clojure) @@ -2947,6 +2947,10 @@ {:excludes #{} :renames {}} args)) +(defn parse-ns-excludes [env args] + (let [s (parse-ns-excludes-impl env args)] + (update s :excludes into (keys (:renames s))))) + (defn use->require [env [lib & filters :as spec]] (when-not (and (symbol? lib) (odd? (count spec))) (throw diff --git a/src/test/cljs/cljs/ns_test.cljs b/src/test/cljs/cljs/ns_test.cljs index 2cb85865c..7243eae0a 100644 --- a/src/test/cljs/cljs/ns_test.cljs +++ b/src/test/cljs/cljs/ns_test.cljs @@ -48,3 +48,7 @@ (deftest test-cljs-3399 (is (= ::fake/foo :fake.ns/foo) (is (= `fake/foo 'fake.ns/foo)))) + +(deftest test-cljs-2292 + (is (= false (exists? mapv))) + (is (= true (exists? core-mapv)))) diff --git a/src/test/clojure/cljs/analyzer_tests.clj b/src/test/clojure/cljs/analyzer_tests.clj index e96b6ae3f..5fc39f503 100644 --- a/src/test/clojure/cljs/analyzer_tests.clj +++ b/src/test/clojure/cljs/analyzer_tests.clj @@ -379,6 +379,14 @@ :renames {}})) (is (set? (:excludes parsed))))) + +(deftest test-cljs-2292 + (let [parsed (ana/parse-ns-excludes {} '((:refer-clojure :rename {map clj-map})))] + (is (= parsed + '{:excludes #{map} + :renames {map clj-map}})) + (is (set? (:excludes parsed))))) + (deftest test-cljs-1785-js-shadowed-by-local (let [ws (atom [])] (ana/with-warning-handlers [(collecting-warning-handler ws)]