You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There seems to be a problem with passing an object using recursion where the value passed is null.
This code
function clone (obj) {
var cloned;
if (isType(obj, 'Object') ) {
cloned = {};
Object.keys(obj).forEach(function (key) {
cloned[key] = clone(obj[key]);
});
} else {
cloned = obj;
}
return cloned;
}
function isType (obj, type) {
if (type === 'Undefined') {
return typeof obj === 'undefined';
} else {
return Object.prototype.toString.call(obj) === '[object ' + type + ']';
}
}
var obj = {a: {b: {c: {d: 1}}, e: {f: 2}}}
obj.a.b.c.d = null
var b = clone(obj)
works fine using node 0.10.32 but fails with the following error when run using triereme
TypeError: Expected argument of type object, but instead had type object
TypeError: Expected argument of type object, but instead had type object
at clone (C:\git\Source\Repos\jlapigee\api\test-api\test.js:7)
at C:\git\Source\Repos\jlapigee\api\test-api\test.js:8
at clone (C:\git\Source\Repos\jlapigee\api\test-api\test.js:7)
at C:\git\Source\Repos\jlapigee\api\test-api\test.js:8
at clone (C:\git\Source\Repos\jlapigee\api\test-api\test.js:7)
at C:\git\Source\Repos\jlapigee\api\test-api\test.js:8
at clone (C:\git\Source\Repos\jlapigee\api\test-api\test.js:7)
at C:\git\Source\Repos\jlapigee\api\test-api\test.js:8
at clone (C:\git\Source\Repos\jlapigee\api\test-api\test.js:7)
at C:\git\Source\Repos\jlapigee\api\test-api\test.js:28
at module.js:456
at module.js:474
at module.js:356
at module.js:312
at module.js:497
at startup (trireme.js:142)
at trireme.js:923
The text was updated successfully, but these errors were encountered:
Thank you for pulling together this nice reproducer. It breaks the same way for me.
The weird thing is that the code works fine in Rhino. It's just Trireme that is causing this behavior, by somehow doing something to the value of "null."
I don't know what is going on there yet unfortunately.
I just tried to reproduce this and the sample script above runs without issue, as in no error produced. I do think this is related to #157 since any function called with null as the sole argument would end up with the argument being replaced with the global object.
There seems to be a problem with passing an object using recursion where the value passed is null.
This code
works fine using node 0.10.32 but fails with the following error when run using triereme
The text was updated successfully, but these errors were encountered: