Skip to content

Commit 7f7a986

Browse files
cljs-2292 refer-clojure rename should also exclude (#240)
Co-authored-by: Enzzo Cavallo <[email protected]>
1 parent b3a6f4f commit 7f7a986

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/main/clojure/cljs/analyzer.cljc

+5-1
Original file line numberDiff line numberDiff line change
@@ -2907,7 +2907,7 @@
29072907
(parse-ns-error-msg spec
29082908
"Each of :as and :refer options may only be specified once in :require / :require-macros"))))))
29092909

2910-
(defn parse-ns-excludes [env args]
2910+
(defn- parse-ns-excludes-impl [env args]
29112911
(reduce
29122912
(fn [s [k & filters]]
29132913
(if (= k :refer-clojure)
@@ -2947,6 +2947,10 @@
29472947
{:excludes #{}
29482948
:renames {}} args))
29492949

2950+
(defn parse-ns-excludes [env args]
2951+
(let [s (parse-ns-excludes-impl env args)]
2952+
(update s :excludes into (keys (:renames s)))))
2953+
29502954
(defn use->require [env [lib & filters :as spec]]
29512955
(when-not (and (symbol? lib) (odd? (count spec)))
29522956
(throw

src/test/cljs/cljs/ns_test.cljs

+4
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,7 @@
4848
(deftest test-cljs-3399
4949
(is (= ::fake/foo :fake.ns/foo)
5050
(is (= `fake/foo 'fake.ns/foo))))
51+
52+
(deftest test-cljs-2292
53+
(is (= false (exists? mapv)))
54+
(is (= true (exists? core-mapv))))

src/test/clojure/cljs/analyzer_tests.clj

+9-1
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@
338338
'(ns foo.core
339339
(:refer-clojure :rename {when always
340340
map core-map}))))]
341-
(is (= (-> parsed-ns :excludes) #{}))
341+
(is (= (-> parsed-ns :excludes) '#{when map}))
342342
(is (= (-> parsed-ns :rename-macros) '{always cljs.core/when}))
343343
(is (= (-> parsed-ns :renames) '{core-map cljs.core/map})))
344344
(is (thrown? Exception (env/with-compiler-env test-cenv
@@ -379,6 +379,14 @@
379379
:renames {}}))
380380
(is (set? (:excludes parsed)))))
381381

382+
383+
(deftest test-cljs-2292
384+
(let [parsed (ana/parse-ns-excludes {} '((:refer-clojure :rename {map clj-map})))]
385+
(is (= parsed
386+
'{:excludes #{map}
387+
:renames {map clj-map}}))
388+
(is (set? (:excludes parsed)))))
389+
382390
(deftest test-cljs-1785-js-shadowed-by-local
383391
(let [ws (atom [])]
384392
(ana/with-warning-handlers [(collecting-warning-handler ws)]

0 commit comments

Comments
 (0)