Index: src/symbol.js |
diff --git a/src/symbol.js b/src/symbol.js |
index 1e65cb859da2543629f22028aa619a1b02e1a15e..897d78e146d9a19299c9e4fa0b804a5b6a4b99d7 100644 |
--- a/src/symbol.js |
+++ b/src/symbol.js |
@@ -30,7 +30,8 @@ |
var $Symbol = global.Symbol; |
function SymbolConstructor(x) { |
- var value = IS_SYMBOL(x) ? x : %CreateSymbol(); |
+ var value = |
+ IS_SYMBOL(x) ? x : %CreateSymbol(IS_UNDEFINED(x) ? x : ToString(x)); |
if (%_IsConstructCall()) { |
%_SetValueOf(this, value); |
} else { |
@@ -38,6 +39,16 @@ function SymbolConstructor(x) { |
} |
} |
+function SymbolGetName() { |
+ var symbol = IS_SYMBOL_WRAPPER(this) ? %_ValueOf(this) : this; |
+ if (!IS_SYMBOL(symbol)) { |
+ throw MakeTypeError( |
+ 'incompatible_method_receiver', ["Symbol.prototype.name", this]); |
+ |
+ } |
+ return %SymbolName(symbol); |
+} |
+ |
function SymbolToString() { |
throw new $TypeError("Symbol.prototype.toString is not allowed"); |
} |
@@ -60,6 +71,7 @@ function SetUpSymbol() { |
%FunctionSetPrototype($Symbol, new $Symbol()); |
%SetProperty($Symbol.prototype, "constructor", $Symbol, DONT_ENUM); |
+ InstallGetter($Symbol.prototype, "name", SymbolGetName); |
InstallFunctions($Symbol.prototype, DONT_ENUM, $Array( |
"toString", SymbolToString, |
"valueOf", SymbolValueOf |