Skip to content

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

@sunlili

Description

@sunlili

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 (<anonymous>)
    at int16Array.js:31:31

ICT BT group
2017.8.15

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions