Bug 1793959 - Add ThrowMsgKind::DecoratorInvalidReturnType; r=mgaudet

We'll need to be able to throw a TypeError if the decorator returns something
other than a callable or undefined.

Differential Revision: https://phabricator.services.mozilla.com/D162140
This commit is contained in:
Dan Minor 2022-11-23 16:47:13 +00:00
parent 2755bc5a1c
commit 3a86e5a300
3 changed files with 7 additions and 0 deletions

View File

@ -799,4 +799,7 @@ MSG_DEF(JSMSG_SHADOW_REALM_EXPORT_NOT_STRING, 0, JSEXN_TYPEERR, "exportName m
MSG_DEF(JSMSG_SHADOW_REALM_IMPORTVALUE_FAILED, 0, JSEXN_TYPEERR, "import value failed")
MSG_DEF(JSMSG_SHADOW_REALM_VALUE_NOT_EXPORTED, 0, JSEXN_TYPEERR, "value not exported")
// Decorators
MSG_DEF(JSMSG_DECORATOR_INVALID_RETURN_TYPE, 0, JSEXN_TYPEERR, "Invalid value returned from decorator: decorators can only return undefined or a callable")
//clang-format on

View File

@ -28,6 +28,8 @@ JSErrNum js::ThrowMsgKindToErrNum(ThrowMsgKind kind) {
return JSMSG_SET_MISSING_PRIVATE;
case ThrowMsgKind::AssignToPrivateMethod:
return JSMSG_ASSIGN_TO_PRIVATE_METHOD;
case ThrowMsgKind::DecoratorInvalidReturnType:
return JSMSG_DECORATOR_INVALID_RETURN_TYPE;
}
MOZ_CRASH("Unexpected message kind");

View File

@ -23,6 +23,8 @@ enum class ThrowMsgKind : uint8_t {
MissingPrivateOnGet,
MissingPrivateOnSet,
AssignToPrivateMethod,
// Decorators:
DecoratorInvalidReturnType,
};
JSErrNum ThrowMsgKindToErrNum(ThrowMsgKind kind);