Details
-
Type:
Defect
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Completed
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Patch:Code
Description
js->clj loops infinitely on some native objects because it thinks they're maps and recurses on the ClojureScript metadata properties. It gets stuck because the ClojureScript metadata properties themselves have properties. For example
(js->clj (js/Date.))
gets stuck because it calls itself again on Date's cljs$core$IEquiv$_equiv property, which in turn has a cljs$core$IPrintable$_pr_seq. At this point the loop repeats and until it blows the stack.
The bigger problem is that js->clj converts any kind of object to a map, but this doesn't make sense for something like Date or RegExp. I think the best fix would be to only convert plain objects with no parent constructor to maps and leave any other objects alone. Here's a small patch to fix this: https://gist.github.com/2282085
Fixed, https://github.com/clojure/clojurescript/commit/ebf45f5f4ecdb6032c06fcffee8c0af59fc09af1