Comment #1 on issue 1955 by [email protected]: Move all V8-internal JS to
strict mode
http://code.google.com/p/v8/issues/detail?id=1955
Ad 1, that's deliberate behavior. The specification is pretty clear, and
built-in functions don't satisfy the requirements for being strict. Making
them strict would be a spec violation and it is detectable.
E.g.:
// SHOULD NOT THROW
[1,2].sort(function foo(a,b) {
alert(foo.caller);
alert(Array.prototype.sort.arguments);
alert(Array.prototype.sort.caller);
return b - a;
});
The first alert is the most important one. It doesn't read any property of
the builtin sort function, only on the non-strict "foo" function. However,
if sort is strict, it throws, and if sort isn't strict, it doesn't. That's
a spec-guaranteed test for a function being strict, and sort shouldn't be.
We can change the value of foo.caller, since that's not specified, but I'll
bet there is code out there using it.
That is, any function that is native (as marked by %SetNativeFlag) should
not be considered strict, even if it's defined in an (otherwise strict)
library. The non-user reachable builtin functions (helper functions) are
free to be strict.
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev