Throw error for using rest parameter in property setter (#3335)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
@@ -1137,6 +1137,10 @@ parser_error_to_string (parser_error_t error) /**< error code */
|
||||
{
|
||||
return "Rest parameter must be the last formal parameter.";
|
||||
}
|
||||
case PARSER_ERR_SETTER_REST_PARAMETER:
|
||||
{
|
||||
return "Setter function argument must not be a rest parameter.";
|
||||
}
|
||||
case PARSER_ERR_REST_PARAMETER_DEFAULT_INITIALIZER:
|
||||
{
|
||||
return "Rest parameter may not have a default initializer.";
|
||||
|
||||
@@ -1638,6 +1638,10 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
else if (context_p->token.type == LEXER_THREE_DOTS)
|
||||
{
|
||||
if (context_p->status_flags & PARSER_IS_PROPERTY_SETTER)
|
||||
{
|
||||
parser_raise_error (context_p, PARSER_ERR_SETTER_REST_PARAMETER);
|
||||
}
|
||||
lexer_next_token (context_p);
|
||||
|
||||
if (duplicated_argument_names)
|
||||
|
||||
@@ -127,6 +127,7 @@ typedef enum
|
||||
PARSER_ERR_OF_EXPECTED, /**< of keyword expected */
|
||||
|
||||
PARSER_ERR_FORMAL_PARAM_AFTER_REST_PARAMETER, /**< formal parameter after rest parameter */
|
||||
PARSER_ERR_SETTER_REST_PARAMETER, /**< setter rest parameter */
|
||||
PARSER_ERR_REST_PARAMETER_DEFAULT_INITIALIZER, /**< rest parameter default initializer */
|
||||
PARSER_ERR_DUPLICATED_ARGUMENT_NAMES, /**< duplicated argument names */
|
||||
PARSER_ERR_INVALID_DESTRUCTURING_PATTERN, /**< invalid destructuring pattern */
|
||||
|
||||
@@ -35,6 +35,7 @@ CheckSyntaxError ('function x (... c = 5) {}');
|
||||
CheckSyntaxError ('function x (...) {}');
|
||||
CheckSyntaxError ('function x (a, a, ...a) {}');
|
||||
CheckSyntaxError ('"use strict" function x (...arguments) {}');
|
||||
CheckSyntaxError ('var o = { set e (...args) { } }');
|
||||
|
||||
rest_params = ['hello', true, 7, {}, [], function () {}];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user