mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 22:27:35 +00:00
LibJS: Don't create StringOrSymbol(String) if from_value() fails
If value.to_string() throws an exception and returns a null string we must create an invalid StringOrSymbol, not one from the null string (which ASSERT()s).
This commit is contained in:
parent
a0130b55d4
commit
965050796f
1 changed files with 6 additions and 3 deletions
|
@ -37,11 +37,14 @@ class StringOrSymbol {
|
|||
public:
|
||||
static StringOrSymbol from_value(GlobalObject& global_object, Value value)
|
||||
{
|
||||
if (value.is_empty())
|
||||
return {};
|
||||
if (value.is_symbol())
|
||||
return &value.as_symbol();
|
||||
if (!value.is_empty())
|
||||
return value.to_string(global_object);
|
||||
return {};
|
||||
auto string = value.to_string(global_object);
|
||||
if (string.is_null())
|
||||
return {};
|
||||
return string;
|
||||
}
|
||||
|
||||
StringOrSymbol() = default;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue