Skip to content

Commit 8ecf8b2

Browse files
committed
fix deftype
1 parent 893fc83 commit 8ecf8b2

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/sci/impl/deftype.cljc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@
9292
(let [ctx (store/get-ctx)]
9393
(if (:sci.impl/macroexpanding ctx)
9494
(cons 'clojure.core/deftype (rest form))
95-
(let [factory-fn-str (str "->" record-name)
95+
(let [fields (mapv #(with-meta (munge %) (meta %)) fields)
96+
factory-fn-str (str "->" record-name)
9697
factory-fn-sym (symbol factory-fn-str)
9798
rec-type (symbol (str (munge (utils/current-ns-name)) "." record-name))
9899
protocol-impls (utils/split-when symbol? raw-protocol-impls)

test/sci/interop_test.cljc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,3 +379,7 @@
379379
(is (= 1 (sci/eval-string "(def x #js {:foo_bar 1}) (.-foo-bar x)" {:classes {:allow :all}})))
380380
(is (= 1 (sci/eval-string "(def x #js {:foo_bar (fn [] 1)}) (.foo-bar x)" {:classes {:allow :all}})))
381381
(is (= {:foo_bar 1} (sci/eval-string "(js->clj (doto #js {} (set! -foo-bar 1)) :keywordize-keys true)" {:classes {:allow :all}})))))
382+
383+
(deftest issue-987-deftype-munged-fields-test
384+
(is (= 1 (sci/eval-string "(deftype Foo [foo-bar]) (.-foo-bar (->Foo 1))" {:classes {:allow :all}})))
385+
(is (= 1 (sci/eval-string "(deftype Foo [foo-bar]) (.-foo_bar (->Foo 1))" {:classes {:allow :all}}))))

0 commit comments

Comments
 (0)