Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Fix error for static class methods named prototype #2552

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion boa_engine/src/vm/opcode/define/class/getter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ impl Operation for DefineClassStaticGetterByValue {
.as_ref()
.and_then(PropertyDescriptor::set)
.cloned();
class.__define_own_property__(
class.define_property_or_throw(
key,
PropertyDescriptor::builder()
.maybe_get(Some(function))
Expand Down
2 changes: 1 addition & 1 deletion boa_engine/src/vm/opcode/define/class/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ impl Operation for DefineClassStaticMethodByValue {
function_mut.set_home_object(class.clone());
function_mut.set_class_object(class.clone());
}
class.__define_own_property__(
class.define_property_or_throw(
key,
PropertyDescriptor::builder()
.value(function)
Expand Down
2 changes: 1 addition & 1 deletion boa_engine/src/vm/opcode/define/class/setter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ impl Operation for DefineClassStaticSetterByValue {
.as_ref()
.and_then(PropertyDescriptor::get)
.cloned();
class.__define_own_property__(
class.define_property_or_throw(
key,
PropertyDescriptor::builder()
.maybe_set(Some(function))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ where

match class_element_name {
ClassElementName::PropertyName(property_name) if r#static => {
if property_name.prop_name() == Some(Sym::PROTOTYPE) {
if property_name.literal() == Some(Sym::PROTOTYPE) {
return Err(Error::general(
"class may not have static method definitions named 'prototype'",
name_position,
Expand Down Expand Up @@ -780,7 +780,7 @@ where
cursor.set_strict_mode(strict);
match class_element_name {
ClassElementName::PropertyName(property_name) if r#static => {
if property_name.prop_name() == Some(Sym::PROTOTYPE) {
if property_name.literal() == Some(Sym::PROTOTYPE) {
return Err(Error::general(
"class may not have static method definitions named 'prototype'",
name_position,
Expand Down Expand Up @@ -825,11 +825,11 @@ where

match class_element_name {
ClassElementName::PropertyName(property_name) if r#static => {
if property_name.prop_name() == Some(Sym::PROTOTYPE) {
if property_name.literal() == Some(Sym::PROTOTYPE) {
return Err(Error::general(
"class may not have static method definitions named 'prototype'",
name_position,
));
"class may not have static method definitions named 'prototype'",
name_position,
));
}
function::ClassElement::StaticMethodDefinition(
property_name,
Expand Down Expand Up @@ -957,13 +957,11 @@ where
body,
));
if r#static {
if let Some(name) = name.prop_name() {
if name == Sym::PROTOTYPE {
return Err(Error::general(
"class may not have static method definitions named 'prototype'",
name_position,
));
}
if name.literal() == Some(Sym::PROTOTYPE) {
return Err(Error::general(
"class may not have static method definitions named 'prototype'",
name_position,
));
}
function::ClassElement::StaticMethodDefinition(name, method)
} else {
Expand Down Expand Up @@ -1081,13 +1079,11 @@ where
cursor.set_strict_mode(strict);
let method = MethodDefinition::Set(Function::new(None, params, body));
if r#static {
if let Some(name) = name.prop_name() {
if name == Sym::PROTOTYPE {
return Err(Error::general(
"class may not have static method definitions named 'prototype'",
name_position,
));
}
if name.literal() == Some(Sym::PROTOTYPE) {
return Err(Error::general(
"class may not have static method definitions named 'prototype'",
name_position,
));
}
function::ClassElement::StaticMethodDefinition(name, method)
} else {
Expand Down Expand Up @@ -1253,13 +1249,11 @@ where
}
}
TokenKind::Punctuator(Punctuator::OpenParen) => {
if let Some(name) = name.prop_name() {
if r#static && name == Sym::PROTOTYPE {
return Err(Error::general(
"class may not have static method definitions named 'prototype'",
name_position,
));
}
if r#static && name.literal() == Some(Sym::PROTOTYPE) {
return Err(Error::general(
"class may not have static method definitions named 'prototype'",
name_position,
));
}
let strict = cursor.strict_mode();
cursor.set_strict_mode(true);
Expand Down