Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1715)

Unified Diff: src/runtime.js

Issue 5950001: Change DefaultString and DefaultNumber to match the spec required behavior. (Closed)
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/object-toprimitive.js » ('j') | test/mjsunit/object-toprimitive.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.js
diff --git a/src/runtime.js b/src/runtime.js
index f2c8d6b84622fb0355eed6f6ddb190701ebb1ae6..28a38ca896b5ef167116720c2f9c4e1fd039a165 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -594,13 +594,15 @@ function IsPrimitive(x) {
// ECMA-262, section 8.6.2.6, page 28.
function DefaultNumber(x) {
- if (IS_FUNCTION(x.valueOf)) {
- var v = x.valueOf();
+ var valueOf = x.valueOf;
+ if (IS_FUNCTION(valueOf)) {
+ var v = %_CallFunction(x, valueOf);
if (%IsPrimitive(v)) return v;
}
- if (IS_FUNCTION(x.toString)) {
- var s = x.toString();
+ var toString = x.toString;
+ if (IS_FUNCTION(toString)) {
+ var s = %_CallFunction(x, toString);
if (%IsPrimitive(s)) return s;
}
@@ -610,13 +612,15 @@ function DefaultNumber(x) {
// ECMA-262, section 8.6.2.6, page 28.
function DefaultString(x) {
- if (IS_FUNCTION(x.toString)) {
- var s = x.toString();
+ var toString = x.toString;
+ if (IS_FUNCTION(toString)) {
+ var s = %_CallFunction(x, toString);
if (%IsPrimitive(s)) return s;
}
- if (IS_FUNCTION(x.valueOf)) {
- var v = x.valueOf();
+ var valueOf = x.valueOf;
+ if (IS_FUNCTION(valueOf)) {
+ var v = %_CallFunction(x, valueOf);
if (%IsPrimitive(v)) return v;
}
« no previous file with comments | « no previous file | test/mjsunit/object-toprimitive.js » ('j') | test/mjsunit/object-toprimitive.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698