Comment #2 on issue 760 by [email protected]: [[DefaultValue]] discrepancy
http://code.google.com/p/v8/issues/detail?id=760

I think there is a mistake in the description of how to achieve the result. The Addition operator is described like this in ECMA-252 5th edition:

1. Let lref be the result of evaluating AdditiveExpression.
2. Let lval be GetValue(lref).
3. Let rref be the result of evaluating MultiplicativeExpression.
4. Let rval be GetValue(rref).
5. Let lprim be ToPrimitive(lval).
6. Let rprim be ToPrimitive(rval).
7. If Type(lprim) is String or Type(rprim) is String, then
a. Return the String that is the result of concatenating ToString(lprim) followed by ToString(rprim) 8. Return the result of applying the addition operation to ToNumber(lprim) and ToNumber(rprim). See the
   Note below 11.6.3.

So `o + ''` will ToString on the result of ToPrimitive(o) with no hint, so as far as I can see having String.prototype.toString return a non primitive result does not matter in this case.

If we did

  String.prototype.toString = function() { return 'z' };

above then `String(o)` would not be the same as `o + ''`. `String(o)` would be 'z' and `o + ''` would be 'y'.

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to