Comment #3 on issue 760 by [email protected]: [[DefaultValue]]
discrepancy
http://code.google.com/p/v8/issues/detail?id=760
It is correct that the overwritten toString doesn't matter.
The problem doesn't need ToString, though. The call to ToPrimitive with no
hint should call the "valueOf" function on the object, returning 'y'. We
return 'x'.
A shorter example:
String.prototype.valueOf = function() { return 'y'; };
print(Object('x') + ''); // Should print 'y', prints 'x'.
Adding output to the valueOf function shows that it is never called.
Curiously:
String.prototype.valueOf = function() { return 'y'; };
var o = Object('x');
print(o + o); // Correctly prints 'yy', and calls valueOf twice.
print(o + ''); // Incorrectly prints 'x' and never calls valueOf.
Seems like an optimization being too optimistic.
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev