chakra-core / chakra-core/ChakraCore

Realization of TypedArray's [[DefineOwnProperty]] is inconsistent with other engines

Open
#3,532 3 comments 0 reactions 0 assignees View on GitHub
Bug Severity: 2
Dominant language
JavaScript
Stars
9.3k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

Hello,
The following code behaves inconsistent with other engines.
```
var get_cnt = 0;
var int16 = new Int16Array(4);
class dummy {
constructor() {
print("in constructor");
return int16;
}
}

var handler = {
get: function(oTarget, sKey) {
print("get " + sKey.toString());
if (sKey.toString()=="constructor") {
return { [Symbol.species] : dummy };
} else if (Number(sKey.toString()) != NaN) {
get_cnt++;
return 0x10;
}
return Reflect.get(oTarget, sKey);
},
has: function (oTarget, sKey) {
print("has " + sKey.toString());
return Reflect.has(oTarget, sKey);
},
};

var words1 = ["abc", "aaaaaaa", "abcd", "aaaaabcd", "abcde", "aaaaabcdef"];
var words2 = ["abc", "aaaaaaa", "abcd", "aaaaabcd", "abcde", "aaaaabcdef"];
var p = new Proxy(words2, handler);

var longWords = words1.filter.call(p, function(word){
return true;
});

print(longWords);
```

Chakra 1.7-release result:
```
get length
get constructor
in constructor
has 0
get 0
has 1
get 1
has 2
get 2
has 3
get 3
has 4
get 4
has 5
get 5
has 6
has 7
has 8
has 9
has 10
has 11
has 12
has 13
has 14
has 15
16,16,16,16
```
spidermonkey result:
```
get length
get constructor
in constructor
has 0
get 0
int16Array.js:31:17 TypeError: can't redefine non-configurable property 0
```
v8 result:
```
get length
get constructor
in constructor
has 0
get 0
int16Array.js:31: TypeError: Cannot redefine property: 0
var longWords = words1.filter.call(p, function(word){
^
TypeError: Cannot redefine property: 0
at Proxy.filter ()
at int16Array.js:31:31
```

ICT BT group
2017.8.15

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.