Status: New
Owner: ----
New issue 2449 by [email protected]: Number.prototype.{toFixed,
toPrecision,toExponential, toLocaleString} are not generic
http://code.google.com/p/v8/issues/detail?id=2449
See [15.7.4 Properties of the Number Prototype Object]:
---
[...]
Unless explicitly stated otherwise, the methods of the Number prototype
object defined below are not generic and the this value passed to them must
be either a Number value or an Object for which the value of the [[Class]]
internal property is "Number".
[...]
A TypeError exception is thrown if the this value is neither an object
for which the value of the [[Class]] internal property is "Number" or a
value whose type is Number.
---
test case:
---
Number.prototype.toFixed.call({valueOf: function(){throw "value-of
called"}}, 1)
Number.prototype.toPrecision.call({valueOf: function(){throw "value-of
called"}}, 1)
Number.prototype.toExponential.call({valueOf: function(){throw "value-of
called"}}, 1)
Number.prototype.toLocaleString.call({valueOf: function(){throw "value-of
called"}})
---
Expected result:
Each function call should have raised a TypeError exception instead of
calling the `valueOf` function.
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev