swannodette / mori

ClojureScript's persistent data structures and supporting API from the comfort of vanilla JavaScript

Home Page:http://swannodette.github.io/mori

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

toClj throws exception for js object with property "j" having a numeric value

noonian opened this issue · comments

This is a funny one.

Using node 7.4.0 and mori 0.3.2:

> var m = require("mori");
undefined
> m.toClj({j: 42});
Error: No protocol method IEmptyableCollection.-empty defined for type object: [object Object]
    at x (/Users/jed/tmp/node_modules/mori/mori.js:17:63)
    at Na (/Users/jed/tmp/node_modules/mori/mori.js:19:96)
    at Oc (/Users/jed/tmp/node_modules/mori/mori.js:59:358)
    at v (/Users/jed/tmp/node_modules/mori/mori.js:385:474)
    at Function.b [as d] (/Users/jed/tmp/node_modules/mori/mori.js:387:109)
    at Function.a [as b] (/Users/jed/tmp/node_modules/mori/mori.js:385:42)
    at Object.b (/Users/jed/tmp/node_modules/mori/mori.js:422:95)
    at Object.c [as toClj] (/Users/jed/tmp/node_modules/mori/mori.js:422:168)
    at repl:1:3
    at realRunInThisContextScript (vm.js:22:35)
> 

Adding other properties does not change the behavior. Changing "j" to anything else seems to avoid the issue.

It only seems to happen for objects with property "j" having a numeric value like 10 or 10.5.

Object, string, and array values do not trigger the exception.