Skip to content

Commit 425e835

Browse files
authored
Fix regression introduced by #987 (#993)
1 parent 893fc83 commit 425e835

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/sci/impl/evaluator.cljc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@
118118

119119
(def none-sentinel #?(:clj (Object.) :cljs (js/Object.)))
120120

121-
(defn get-from-type [instance method-str method-str-unmunged #?(:clj arg-count :cljs args)]
121+
(defn get-from-type [instance _method-str method-str-unmunged #?(:clj arg-count :cljs args)]
122122
(if (zero? #?(:clj arg-count :cljs (alength args)))
123123
(if (instance? sci.impl.records.SciRecord instance)
124124
(get instance (keyword method-str-unmunged) none-sentinel)
125125
(if (instance? sci.impl.deftype.SciType instance)
126-
(get (types/getVal instance) (symbol method-str) none-sentinel)
126+
(get (types/getVal instance) (symbol method-str-unmunged) none-sentinel)
127127
none-sentinel))
128128
none-sentinel))
129129

test/sci/interop_test.cljc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,3 +379,11 @@
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+
#?(:clj
384+
(deftest issue-987-deftype-munged-fields-test
385+
;; these cases don't work in CLJS yet because {:classes {:allow :all}} takes the fast path
386+
;; perhaps we can fix this by exposing the deftype as an Object in CLJS with mutated fields
387+
(is (= 1 (sci/eval-string "(deftype Foo [foo-bar]) (.-foo-bar (->Foo 1))" {:classes {:allow :all}})))
388+
;; this doesn't work yet either, but not common in Clojure
389+
#_(is (= 1 (sci/eval-string "(deftype Foo [foo-bar]) (.-foo_bar (->Foo 1))" {:classes {:allow :all}})))))

0 commit comments

Comments
 (0)