mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 09:18:11 +00:00
LibJS: Fix casting a value to ScriptFunction without checking it's one
This commit is contained in:
parent
1274c244d5
commit
53a94b8bbd
3 changed files with 6 additions and 4 deletions
|
@ -52,9 +52,9 @@ static void update_function_name(Value& value, const FlyString& name)
|
|||
return;
|
||||
auto& object = value.as_object();
|
||||
if (object.is_function()) {
|
||||
auto& function = static_cast<ScriptFunction&>(object);
|
||||
if (function.name().is_empty())
|
||||
function.set_name(name);
|
||||
auto& function = static_cast<Function&>(object);
|
||||
if (function.is_script_function() && function.name().is_empty())
|
||||
static_cast<ScriptFunction&>(function).set_name(name);
|
||||
} else if (object.is_array()) {
|
||||
auto& array = static_cast<Array&>(object);
|
||||
for (auto& entry : array.indexed_properties().values_unordered())
|
||||
|
|
|
@ -42,6 +42,8 @@ public:
|
|||
|
||||
virtual void visit_children(Visitor&) override;
|
||||
|
||||
virtual bool is_script_function() const { return false; }
|
||||
|
||||
BoundFunction* bind(Value bound_this_value, Vector<Value> arguments);
|
||||
|
||||
Value bound_this() const
|
||||
|
|
|
@ -48,7 +48,7 @@ public:
|
|||
void set_name(const FlyString& name) { m_name = name; };
|
||||
|
||||
private:
|
||||
virtual bool is_script_function() const final { return true; }
|
||||
virtual bool is_script_function() const override { return true; }
|
||||
virtual const char* class_name() const override { return "ScriptFunction"; }
|
||||
virtual LexicalEnvironment* create_environment() override;
|
||||
virtual void visit_children(Visitor&) override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue