Skip to content

Commit 9dafe7d

Browse files
anmonteirodnolen
authored andcommitted
CLJS-2010: refer-clojure :rename throws on valid invocations
1 parent 837aeaf commit 9dafe7d

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/main/clojure/cljs/analyzer.cljc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2058,15 +2058,15 @@
20582058
(let [refs (second fs)]
20592059
(cond
20602060
(not (or (and (= kw :exclude) (sequential? refs) (every? symbol? refs))
2061-
(and (= kw :rename) (map? refs) (every? #(every? symbol? %) refs))))
2061+
(and (= kw :rename) (map? refs) (every? #(every? symbol? %) refs))))
20622062
(recur fs ret true)
20632063

20642064
(= kw :exclude)
20652065
(recur (nnext fs) (update-in ret [:excludes] into refs) false)
20662066

20672067
(= kw :rename)
20682068
(recur (nnext fs) (update-in ret [:renames] merge refs) false)))
2069-
(recur fs ret true )))
2069+
(recur fs ret true)))
20702070

20712071
:else ret))]
20722072
(merge-with into s xs)))
@@ -2238,7 +2238,7 @@
22382238
(if (keyword? quoted-spec-or-kw)
22392239
quoted-spec-or-kw
22402240
(as-> (second quoted-spec-or-kw) spec
2241-
(if (vector? spec) spec [spec]))))]
2241+
(if (or (vector? spec) (map? spec)) spec [spec]))))]
22422242
(map canonicalize specs)))
22432243

22442244
(defn canonicalize-import-specs [specs]

src/test/clojure/cljs/analyzer_tests.clj

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,9 @@
490490
(is (= (a/canonicalize-specs '(:require (quote [clojure.set :as set])))
491491
'(:require [clojure.set :as set])))
492492
(is (= (a/canonicalize-specs '(:require (quote clojure.set)))
493-
'(:require [clojure.set]))))
493+
'(:require [clojure.set])))
494+
(is (= (a/canonicalize-specs '(:refer-clojure :exclude '[map] :rename '{map core-map}))
495+
'(:refer-clojure :exclude [map] :rename {map core-map}))))
494496

495497
(deftest test-canonicalize-import-specs
496498
(is (= (a/canonicalize-import-specs '(:import (quote [goog Uri])))
@@ -556,6 +558,10 @@
556558
Integer goog.math.Integer})))
557559
(let [test-env (a/empty-env)
558560
parsed (a/analyze test-env '(refer-clojure :exclude '[map mapv]))]
561+
(is (= (-> parsed :excludes)
562+
'#{map mapv})))
563+
(let [test-env (a/empty-env)
564+
parsed (a/analyze test-env '(refer-clojure :exclude '[map mapv] :rename '{mapv core-mapv}))]
559565
(is (= (-> parsed :excludes)
560566
'#{map mapv})))))
561567
(testing "arguments to require should be quoted"
@@ -861,4 +867,4 @@
861867
(map (comp :externs second)
862868
(get @test-cenv ::a/namespaces)))))))
863869

864-
)
870+
)

0 commit comments

Comments
 (0)