Skip to content

Commit 4bcc951

Browse files
Thomas Hellerswannodette
authored andcommitted
Keyword constant name must handle dash and underscore correctly
1 parent 5d87ce3 commit 4bcc951

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

src/clj/cljs/analyzer.clj

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,15 +197,14 @@
197197
`(binding [*cljs-warning-handlers* ~handlers]
198198
~@body))
199199

200-
(def ^:private constant-counter (atom 0))
201-
202200
(defn gen-constant-id [value]
203201
(let [prefix (cond
204202
(keyword? value) "constant$keyword$"
205203
:else
206204
(throw
207-
(Exception. (str "constant type " (type value) " not supported"))))]
208-
(symbol (str prefix (string/replace (munge value) "." "$")))))
205+
(Exception. (str "constant type " (type value) " not supported"))))
206+
name (-> value (str) (subs 1) (string/replace "-" "_DASH_") (munge) (string/replace "." "$"))]
207+
(symbol (str prefix name))))
209208

210209
(defn- register-constant!
211210
([val] (register-constant! nil val))

test/clj/cljs/analyzer_tests.clj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,3 +324,8 @@
324324
;; actual: (not (= #{file-reloading dev client} #{file-reloading dev client core}))
325325
(is (= (set (a/ns-dependents 'utils))
326326
#{'file-reloading 'dev 'client 'core}))))
327+
328+
(deftest test-cljs-1105
329+
;; munge turns - into _, must preserve the dash first
330+
(is (not= (a/gen-constant-id :test-kw)
331+
(a/gen-constant-id :test_kw))))

0 commit comments

Comments
 (0)