objects constructed using call/apply with Language Level 1_8 and above fail to have prototype set #364
Labels
bug
Issues considered a bug
Ecma Incompatibility
Issues about Rhino being incompatible with the EcmaScript spec
String.prototype.constructor.apply(null, ['abc']) +'';
Array.prototype.constructor.apply(null, Array(4)) + '';
Both of these fail when using language levels 1_8 or ES_6. When using language 1_7 and below, they work.
ScriptRuntime.applyOrCall has this condition:
if (callThis == null && cx.hasFeature(Context.FEATURE_OLD_UNDEF_NULL_THIS)) {
callThis = getTopCallScope(cx); // This covers the case of args[0] == (null|undefined) as well.
}
This is what allows 1_7 to work, though I have no idea if this correct per design.
Since this problem isn't limited to a single constructor I'm guessing the problem is in this method. A quick and dirty solution is to call setObjectProtoAndParent() on the result of function.call. This probably requires a condition on the method being a constructor since any function can be called here.
I will be creating a test to show this issue.
The text was updated successfully, but these errors were encountered: