Index: src/runtime.js |
diff --git a/src/runtime.js b/src/runtime.js |
index 2a949ae8d1df89a0794780b25e66706698a34b40..a1673cbf216710193405d45dd809a03bc23b8b94 100644 |
--- a/src/runtime.js |
+++ b/src/runtime.js |
@@ -80,6 +80,8 @@ function EQUALS(y) { |
if (!IS_SPEC_OBJECT(y)) return 1; // not equal |
y = %ToPrimitive(y, NO_HINT); |
} |
+ } else if (IS_SYMBOL_WRAPPER(x) && IS_SYMBOL_WRAPPER(y)) { |
rossberg
2014/02/14 10:55:30
This should be subsumed by the default case below.
sof
2014/02/14 14:20:02
Yes. I noticed we were unnecessarily calling ToPri
|
+ return %_ObjectEquals(x, y) ? 0 : 1; |
} else if (IS_BOOLEAN(x)) { |
if (IS_BOOLEAN(y)) return %_ObjectEquals(x, y) ? 0 : 1; |
if (IS_NULL_OR_UNDEFINED(y)) return 1; |
@@ -501,7 +503,7 @@ function ToPrimitive(x, hint) { |
if (IS_STRING(x)) return x; |
// Normal behavior. |
if (!IS_SPEC_OBJECT(x)) return x; |
- if (IS_SYMBOL_WRAPPER(x)) return %_ValueOf(x); |
+ if (IS_SYMBOL_WRAPPER(x)) throw MakeTypeError('symbol_to_primitive', []); |
if (hint == NO_HINT) hint = (IS_DATE(x)) ? STRING_HINT : NUMBER_HINT; |
return (hint == NUMBER_HINT) ? %DefaultNumber(x) : %DefaultString(x); |
} |
@@ -548,6 +550,7 @@ function ToString(x) { |
if (IS_NUMBER(x)) return %_NumberToString(x); |
if (IS_BOOLEAN(x)) return x ? 'true' : 'false'; |
if (IS_UNDEFINED(x)) return 'undefined'; |
+ if (IS_SYMBOL(x)) throw %MakeTypeError('symbol_to_string', []); |
return (IS_NULL(x)) ? 'null' : %ToString(%DefaultString(x)); |
} |
@@ -555,6 +558,7 @@ function NonStringToString(x) { |
if (IS_NUMBER(x)) return %_NumberToString(x); |
if (IS_BOOLEAN(x)) return x ? 'true' : 'false'; |
if (IS_UNDEFINED(x)) return 'undefined'; |
+ if (IS_SYMBOL(x)) throw %MakeTypeError('symbol_to_string', []); |
return (IS_NULL(x)) ? 'null' : %ToString(%DefaultString(x)); |
} |
@@ -568,9 +572,9 @@ function ToName(x) { |
// ECMA-262, section 9.9, page 36. |
function ToObject(x) { |
if (IS_STRING(x)) return new $String(x); |
- if (IS_SYMBOL(x)) return new $Symbol(x); |
if (IS_NUMBER(x)) return new $Number(x); |
if (IS_BOOLEAN(x)) return new $Boolean(x); |
+ if (IS_SYMBOL(x)) return %NewSymbolWrapper(x); |
if (IS_NULL_OR_UNDEFINED(x) && !IS_UNDETECTABLE(x)) { |
throw %MakeTypeError('undefined_or_null_to_object', []); |
} |