Open sunlili opened 7 years ago
Seems to have to do with the following spec sections.
ArraySpeciesCreate
as well.Perform ? CreateDataPropertyOrThrow(A, ! ToString(to), kValue)
Let success be ? CreateDataProperty(O, P, V).
Return ? O.[[DefineOwnProperty]](P, newDesc).
Reduced repro with some notes in comments. Produces shorter output, shown below.
class dummy {
constructor() {
print("in constructor");
return new Int16Array(4);
}
}
var handler = {
get: function(oTarget, sKey) {
print("get " + sKey.toString());
if (sKey.toString()=="constructor") {
// return function(){}; // no repro
// return { [Symbol.species] : Int16Array }; // ch = sm; disagree with d8
// return { [Symbol.species] : Uint32Array }; // ch = sm; disagree with d8
return { [Symbol.species] : dummy };
} else if (Number(sKey.toString()) != NaN) {
return 4;
}
print(`reflect.get ${oTarget} ${sKey}`);
return Reflect.get(oTarget, sKey);
},
has: function (oTarget, sKey) {
print("has " + sKey.toString());
return Reflect.has(oTarget, sKey);
},
};
var words1 = ["a", 42, {}];
var p = new Proxy(words1, handler);
// var longWords = words1.filter.call(p, function(word){
var boundFilter = (Array.prototype.filter.bind(p));
// var boundFilter = (Array.prototype.concat.bind(p));
// var boundFilter = (Array.prototype.map.bind(p));
// var boundFilter = (Array.prototype.slice.bind(p));
// var boundFilter = (Array.prototype.splice.bind(p)); // disagreement between d8, sm, ch
var longWords = boundFilter(function(word){
print("word = " + word);
return true;
});
print(longWords);
Output:
>eshost -h d8,ch-1.7.1,sm -ts test.js
┌──────────┬───────────────────────────────────────────────────────┐
│ ch-1.7.1 │ get length │
│ │ get constructor │
│ │ in constructor │
│ │ has 0 │
│ │ get 0 │
│ │ word = 4 │
│ │ has 1 │
│ │ get 1 │
│ │ word = 4 │
│ │ has 2 │
│ │ get 2 │
│ │ word = 4 │
│ │ has 3 │
│ │ 4,4,4,0 │
├──────────┼───────────────────────────────────────────────────────┤
│ d8 │ get length │
│ │ get constructor │
│ │ in constructor │
│ │ has 0 │
│ │ get 0 │
│ │ word = 4 │
│ │ TypeError: Cannot redefine property: 0 │
├──────────┼───────────────────────────────────────────────────────┤
│ sm │ get length │
│ │ get constructor │
│ │ in constructor │
│ │ has 0 │
│ │ get 0 │
│ │ word = 4 │
│ │ TypeError: can't redefine non-configurable property 0 │
└──────────┴───────────────────────────────────────────────────────┘
Still repros (included jsc
in this output):
## Source
class dummy {
constructor() {
print("in constructor");
return new Int16Array(4);
}
}
var handler = {
get: function(oTarget, sKey) {
print("get " + sKey.toString());
if (sKey.toString()=="constructor") {
// return function(){}; // no repro
// return { [Symbol.species] : Int16Array }; // ch = sm; disagree with d8
// return { [Symbol.species] : Uint32Array }; // ch = sm; disagree with d8
return { [Symbol.species] : dummy };
} else if (Number(sKey.toString()) != NaN) {
return 4;
}
print(`reflect.get ${oTarget} ${sKey}`);
return Reflect.get(oTarget, sKey);
},
has: function (oTarget, sKey) {
print("has " + sKey.toString());
return Reflect.has(oTarget, sKey);
},
};
var words1 = ["a", 42, {}];
var p = new Proxy(words1, handler);
// var longWords = words1.filter.call(p, function(word){
var boundFilter = (Array.prototype.filter.bind(p));
// var boundFilter = (Array.prototype.concat.bind(p));
// var boundFilter = (Array.prototype.map.bind(p));
// var boundFilter = (Array.prototype.slice.bind(p));
// var boundFilter = (Array.prototype.splice.bind(p)); // disagreement between d8, sm, ch
var longWords = boundFilter(function(word){
print("word = " + word);
return true;
});
print(longWords);
┌──────────┬───────────────────────────────────────────────────────────────────────────────────────────┐
│ jsvu-ch │ get length │
│ │ get constructor │
│ │ in constructor │
│ │ has 0 │
│ │ get 0 │
│ │ word = 4 │
│ │ has 1 │
│ │ get 1 │
│ │ word = 4 │
│ │ has 2 │
│ │ get 2 │
│ │ word = 4 │
│ │ has 3 │
│ │ 4,4,4,0 │
├──────────┼───────────────────────────────────────────────────────────────────────────────────────────┤
│ jsvu-jsc │ get length │
│ │ get constructor │
│ │ in constructor │
│ │ has 0 │
│ │ get 0 │
│ │ word = 4 │
│ │ TypeError: Attempting to configure non-configurable property on a typed array at index: 0 │
├──────────┼───────────────────────────────────────────────────────────────────────────────────────────┤
│ jsvu-sm │ get length │
│ │ get constructor │
│ │ in constructor │
│ │ has 0 │
│ │ get 0 │
│ │ word = 4 │
│ │ TypeError: can't redefine non-configurable property 0 │
├──────────┼───────────────────────────────────────────────────────────────────────────────────────────┤
│ jsvu-v8 │ get length │
│ │ get constructor │
│ │ in constructor │
│ │ has 0 │
│ │ get 0 │
│ │ word = 4 │
│ │ TypeError: Cannot redefine property: 0 │
└──────────┴───────────────────────────────────────────────────────────────────────────────────────────┘
Looks like we'll need to duplicate all the typed arrays vtables to fix this and maintain perf.
Hello, The following code behaves inconsistent with other engines.
Chakra 1.7-release result:
spidermonkey result:
v8 result:
ICT BT group 2017.8.15