1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:47:46 +00:00

LibJS: Store and return undefined Symbol description

Instead of the current incorrect behaviour of just defaulting to an
empty string.
This commit is contained in:
Idan Horowitz 2021-06-15 02:40:55 +03:00 committed by Linus Groh
parent 4aff4249aa
commit dac971b4ae
5 changed files with 17 additions and 19 deletions

View file

@ -42,8 +42,8 @@ SymbolConstructor::~SymbolConstructor()
// 20.4.1.1 Symbol ( [ description ] ), https://tc39.es/ecma262/#sec-symbol-description
Value SymbolConstructor::call()
{
if (!vm().argument_count())
return js_symbol(heap(), "", false);
if (vm().argument(0).is_undefined())
return js_symbol(heap(), {}, false);
return js_symbol(heap(), vm().argument(0).to_string(global_object()), false);
}
@ -57,13 +57,7 @@ Value SymbolConstructor::construct(Function&)
// 20.4.2.2 Symbol.for ( key ), https://tc39.es/ecma262/#sec-symbol.for
JS_DEFINE_NATIVE_FUNCTION(SymbolConstructor::for_)
{
String description;
if (!vm.argument_count()) {
description = "undefined";
} else {
description = vm.argument(0).to_string(global_object);
}
String description = vm.argument(0).to_string(global_object);
return global_object.vm().get_global_symbol(description);
}