mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 10:07:44 +00:00
LibJS: Add missing to_property_key exception check in ClassExpression
This commit is contained in:
parent
9cbd90fdb6
commit
d6df955305
1 changed files with 7 additions and 3 deletions
|
@ -816,20 +816,24 @@ Value ClassExpression::execute(Interpreter& interpreter, GlobalObject& global_ob
|
||||||
if (interpreter.exception())
|
if (interpreter.exception())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
|
auto property_key = key.to_property_key(global_object);
|
||||||
|
if (interpreter.exception())
|
||||||
|
return {};
|
||||||
|
|
||||||
auto& target = method.is_static() ? *class_constructor : class_prototype.as_object();
|
auto& target = method.is_static() ? *class_constructor : class_prototype.as_object();
|
||||||
method_function.set_home_object(&target);
|
method_function.set_home_object(&target);
|
||||||
|
|
||||||
switch (method.kind()) {
|
switch (method.kind()) {
|
||||||
case ClassMethod::Kind::Method:
|
case ClassMethod::Kind::Method:
|
||||||
target.define_property(key.to_property_key(global_object), method_value);
|
target.define_property(property_key, method_value);
|
||||||
break;
|
break;
|
||||||
case ClassMethod::Kind::Getter:
|
case ClassMethod::Kind::Getter:
|
||||||
update_function_name(method_value, String::formatted("get {}", get_function_name(global_object, key)));
|
update_function_name(method_value, String::formatted("get {}", get_function_name(global_object, key)));
|
||||||
target.define_accessor(key.to_property_key(global_object), &method_function, nullptr, Attribute::Configurable | Attribute::Enumerable);
|
target.define_accessor(property_key, &method_function, nullptr, Attribute::Configurable | Attribute::Enumerable);
|
||||||
break;
|
break;
|
||||||
case ClassMethod::Kind::Setter:
|
case ClassMethod::Kind::Setter:
|
||||||
update_function_name(method_value, String::formatted("set {}", get_function_name(global_object, key)));
|
update_function_name(method_value, String::formatted("set {}", get_function_name(global_object, key)));
|
||||||
target.define_accessor(key.to_property_key(global_object), nullptr, &method_function, Attribute::Configurable | Attribute::Enumerable);
|
target.define_accessor(property_key, nullptr, &method_function, Attribute::Configurable | Attribute::Enumerable);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue