@ -112,6 +112,8 @@ impl BuiltIn for Symbol {
)
)
. name ( Self ::NAME )
. name ( Self ::NAME )
. length ( Self ::LENGTH )
. length ( Self ::LENGTH )
. callable ( true )
. constructor ( true )
. static_method ( Self ::for_ , "for" , 1 )
. static_method ( Self ::for_ , "for" , 1 )
. static_method ( Self ::key_for , "keyFor" , 1 )
. static_method ( Self ::key_for , "keyFor" , 1 )
. static_property ( "asyncIterator" , symbol_async_iterator , attribute )
. static_property ( "asyncIterator" , symbol_async_iterator , attribute )
@ -135,8 +137,6 @@ impl BuiltIn for Symbol {
None ,
None ,
Attribute ::CONFIGURABLE | Attribute ::NON_ENUMERABLE ,
Attribute ::CONFIGURABLE | Attribute ::NON_ENUMERABLE ,
)
)
. callable ( true )
. constructor ( false )
. property (
. property (
symbol_to_string_tag ,
symbol_to_string_tag ,
Self ::NAME ,
Self ::NAME ,
@ -173,14 +173,19 @@ impl Symbol {
args : & [ JsValue ] ,
args : & [ JsValue ] ,
context : & mut Context ,
context : & mut Context ,
) -> JsResult < JsValue > {
) -> JsResult < JsValue > {
if new_target . is_undefined ( ) {
// 1. If NewTarget is not undefined, throw a TypeError exception.
if ! new_target . is_undefined ( ) {
return context . throw_type_error ( "Symbol is not a constructor" ) ;
return context . throw_type_error ( "Symbol is not a constructor" ) ;
}
}
// 2. If description is undefined, let descString be undefined.
// 3. Else, let descString be ? ToString(description).
let description = match args . get ( 0 ) {
let description = match args . get ( 0 ) {
Some ( value ) if ! value . is_undefined ( ) = > Some ( value . to_string ( context ) ? ) ,
Some ( value ) if ! value . is_undefined ( ) = > Some ( value . to_string ( context ) ? ) ,
_ = > None ,
_ = > None ,
} ;
} ;
// 4. Return a new unique Symbol value whose [[Description]] value is descString.
Ok ( JsSymbol ::new ( description ) . into ( ) )
Ok ( JsSymbol ::new ( description ) . into ( ) )
}
}