mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 06:38:10 +00:00
LibJS: Add side-effect-free version of Value::to_string()
There are now two API's on Value: - Value::to_string(Interpreter&) -- may throw. - Value::to_string_without_side_effects() -- will never throw. These are some pretty big sweeping changes, so it's possible that I did some part the wrong way. We'll work it out as we go. :^) Fixes #2123.
This commit is contained in:
parent
d8aa2a6997
commit
c6ddbd1f3e
25 changed files with 285 additions and 112 deletions
|
@ -485,7 +485,10 @@ Value Object::to_string() const
|
|||
interpreter.throw_exception<TypeError>("Cannot convert object to string");
|
||||
if (interpreter.exception())
|
||||
return {};
|
||||
return js_string(heap(), to_string_result.to_string());
|
||||
auto* string = to_string_result.to_primitive_string(interpreter);
|
||||
if (interpreter.exception())
|
||||
return {};
|
||||
return string;
|
||||
}
|
||||
return js_string(heap(), String::format("[object %s]", class_name()));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue