From 43e8eb13696eb5fa6bc9110d35806362a8b7b4da Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Sat, 1 Apr 2023 22:32:06 +0200 Subject: [PATCH] CLJS-3401: dedupe '+ and '_PLUS symbols with :optimize-constants --- src/main/clojure/cljs/analyzer.cljc | 6 ++++-- src/test/clojure/cljs/analyzer_tests.clj | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/clojure/cljs/analyzer.cljc b/src/main/clojure/cljs/analyzer.cljc index 574bfe6cc..65f68af46 100644 --- a/src/main/clojure/cljs/analyzer.cljc +++ b/src/main/clojure/cljs/analyzer.cljc @@ -513,14 +513,16 @@ (symbol? value) "cst$sym$" :else (throw - #?(:clj (Exception. (str "constant type " (type value) " not supported")) - :cljs (js/Error. (str "constant type " (type value) " not supported"))))) + #?(:clj (Exception. (str "constant type " (type value) " not supported")) + :cljs (js/Error. (str "constant type " (type value) " not supported"))))) name (if (keyword? value) (subs (str value) 1) (str value)) name (if (= "." name) "_DOT_" (-> name + (string/replace "_" "__") + (string/replace "$" "$$") (string/replace "-" "_DASH_") (munge) (string/replace "." "$") diff --git a/src/test/clojure/cljs/analyzer_tests.clj b/src/test/clojure/cljs/analyzer_tests.clj index 9b823bdac..8ae750ddc 100644 --- a/src/test/clojure/cljs/analyzer_tests.clj +++ b/src/test/clojure/cljs/analyzer_tests.clj @@ -1512,3 +1512,9 @@ (Foo. nil nil))))) (is (= 1 (count @ws))) (is (string/starts-with? (first @ws) "Wrong number of args (2) passed to Foo")))) + +(deftest test-cljs-3401 + (is (not= (ana/gen-constant-id '_PLUS_) + (ana/gen-constant-id '+))) + (is (not= (ana/gen-constant-id 'foo.bar) + (ana/gen-constant-id 'foo$bar))))