Skip to content

Commit 0ccd19f

Browse files
CLJS-3401: dedupe '+ and '_PLUS symbols with :optimize-constants (#203)
Co-authored-by: Michiel Borkent <michielborkent@gmail.com>
1 parent 30171a3 commit 0ccd19f

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/main/clojure/cljs/analyzer.cljc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,14 +513,16 @@
513513
(symbol? value) "cst$sym$"
514514
:else
515515
(throw
516-
#?(:clj (Exception. (str "constant type " (type value) " not supported"))
517-
:cljs (js/Error. (str "constant type " (type value) " not supported")))))
516+
#?(:clj (Exception. (str "constant type " (type value) " not supported"))
517+
:cljs (js/Error. (str "constant type " (type value) " not supported")))))
518518
name (if (keyword? value)
519519
(subs (str value) 1)
520520
(str value))
521521
name (if (= "." name)
522522
"_DOT_"
523523
(-> name
524+
(string/replace "_" "__")
525+
(string/replace "$" "$$")
524526
(string/replace "-" "_DASH_")
525527
(munge)
526528
(string/replace "." "$")

src/test/clojure/cljs/analyzer_tests.clj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,3 +1512,9 @@
15121512
(Foo. nil nil)))))
15131513
(is (= 1 (count @ws)))
15141514
(is (string/starts-with? (first @ws) "Wrong number of args (2) passed to Foo"))))
1515+
1516+
(deftest test-cljs-3401
1517+
(is (not= (ana/gen-constant-id '_PLUS_)
1518+
(ana/gen-constant-id '+)))
1519+
(is (not= (ana/gen-constant-id 'foo.bar)
1520+
(ana/gen-constant-id 'foo$bar))))

0 commit comments

Comments
 (0)