Skip to content

Commit

Permalink
cljs-2292 refer-clojure rename should also exclude
Browse files Browse the repository at this point in the history
  • Loading branch information
souenzzo authored and swannodette committed Nov 30, 2024
1 parent b3a6f4f commit 4eb44ae
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/clojure/cljs/analyzer.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/test/cljs/cljs/ns_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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))))
8 changes: 8 additions & 0 deletions src/test/clojure/cljs/analyzer_tests.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit 4eb44ae

Please sign in to comment.