Skip to content

Commit

Permalink
Keyword constant name must handle dash and underscore correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Heller authored and swannodette committed Mar 11, 2015
1 parent 5d87ce3 commit 4bcc951
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/clj/cljs/analyzer.clj
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,14 @@
`(binding [*cljs-warning-handlers* ~handlers]
~@body))

(def ^:private constant-counter (atom 0))

(defn gen-constant-id [value]
(let [prefix (cond
(keyword? value) "constant$keyword$"
:else
(throw
(Exception. (str "constant type " (type value) " not supported"))))]
(symbol (str prefix (string/replace (munge value) "." "$")))))
(Exception. (str "constant type " (type value) " not supported"))))
name (-> value (str) (subs 1) (string/replace "-" "_DASH_") (munge) (string/replace "." "$"))]
(symbol (str prefix name))))

(defn- register-constant!
([val] (register-constant! nil val))
Expand Down
5 changes: 5 additions & 0 deletions test/clj/cljs/analyzer_tests.clj
Original file line number Diff line number Diff line change
Expand Up @@ -324,3 +324,8 @@
;; actual: (not (= #{file-reloading dev client} #{file-reloading dev client core}))
(is (= (set (a/ns-dependents 'utils))
#{'file-reloading 'dev 'client 'core}))))

(deftest test-cljs-1105
;; munge turns - into _, must preserve the dash first
(is (not= (a/gen-constant-id :test-kw)
(a/gen-constant-id :test_kw))))

0 comments on commit 4bcc951

Please sign in to comment.