Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLJS-2292: refer-clojure rename should also exclude var #240

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading