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

Unified Diff: src/runtime.js

Issue 458753004: ToNumber(Symbol) should throw TypeError (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Use IS_SYMBOL instead Created 6 years, 4 months 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 | « src/messages.js ('k') | src/v8natives.js » ('j') | no next file with comments »
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 c070a1119e7bdadec9679c56e71b435538baa70e..d9e1fe5c994030f40461167faac8b3df4d60ff22 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -36,6 +36,7 @@ function EQUALS(y) {
while (true) {
if (IS_NUMBER(y)) return %NumberEquals(x, y);
if (IS_NULL_OR_UNDEFINED(y)) return 1; // not equal
+ if (IS_SYMBOL(y)) return 1; // not equal
if (!IS_SPEC_OBJECT(y)) {
// String or boolean.
return %NumberEquals(x, %ToNumber(y));
@@ -501,7 +502,7 @@ function ToNumber(x) {
}
if (IS_BOOLEAN(x)) return x ? 1 : 0;
if (IS_UNDEFINED(x)) return NAN;
- if (IS_SYMBOL(x)) return NAN;
+ if (IS_SYMBOL(x)) throw MakeTypeError('symbol_to_number', []);
return (IS_NULL(x)) ? 0 : ToNumber(%DefaultNumber(x));
}
@@ -512,7 +513,7 @@ function NonNumberToNumber(x) {
}
if (IS_BOOLEAN(x)) return x ? 1 : 0;
if (IS_UNDEFINED(x)) return NAN;
- if (IS_SYMBOL(x)) return NAN;
+ if (IS_SYMBOL(x)) throw MakeTypeError('symbol_to_number', []);
return (IS_NULL(x)) ? 0 : ToNumber(%DefaultNumber(x));
}
« no previous file with comments | « src/messages.js ('k') | src/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698