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 Dec 2, 2024
1 parent b3a6f4f commit a7d4b24
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
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))))
10 changes: 9 additions & 1 deletion src/test/clojure/cljs/analyzer_tests.clj
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@
'(ns foo.core
(:refer-clojure :rename {when always
map core-map}))))]
(is (= (-> parsed-ns :excludes) #{}))
(is (= (-> parsed-ns :excludes) '#{when map}))
(is (= (-> parsed-ns :rename-macros) '{always cljs.core/when}))
(is (= (-> parsed-ns :renames) '{core-map cljs.core/map})))
(is (thrown? Exception (env/with-compiler-env test-cenv
Expand Down 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 a7d4b24

Please sign in to comment.