ClojureScript

js->clj loops infinitely on some native objects

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major 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

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: