I agree, this doesn't look like a solid solution.
But I don't want to land a change that switches just
Array.prototype.reverse
into strict mode before we thought through all affected builtin functions
first.
We have following mutator methods on array object: pop(), push(), shift(),
unshift(), splice(), reverse() and sort()
As I identified(maybe there are some other details) only reverse() and
sort()
require element level lookup for property descriptors (frozen state check is
same as for all other mutator methods).
All other methods throw TypeErrors when array is frozen. See examples below:
// initialize and freeze array
var a = [1, 2, 3, 4];
Object.freeze(a);
// Array.prototype.pop
// FF TypeError: property a.pop() is non-configurable and can't be deleted
// WebKit TypeError: Attempted to assign to readonly property.
a.pop();
// Array.prototype.push
// FF TypeError: a.push(0) is not extensible
// WebKit TypeError: Attempted to assign to readonly property.
a.push(0);
// Array.prototype.shift
// FF TypeError: a.shift() is read-only
// WebKit TypeError: Attempted to assign to readonly property.
a.shift();
// Array.prototype.unshift
// FF TypeError: a.unshift(1) is not extensible
// WebKit TypeError: Attempted to assign to readonly property.
a.unshift(1);
// Array.prototype.splice
// FF TypeError: a.splice(0, 1) is read-only
// WebKit TypeError: Attempted to assign to readonly property.
a.splice(0, 1);
https://chromiumcodereview.appspot.com/10453009/
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev