diff options
Diffstat (limited to 'yarp/yarp.c')
-rw-r--r-- | yarp/yarp.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/yarp/yarp.c b/yarp/yarp.c index b641521be5..8fd5392693 100644 --- a/yarp/yarp.c +++ b/yarp/yarp.c @@ -4818,10 +4818,20 @@ yp_parser_local_add_owned(yp_parser_t *parser, const uint8_t *start, size_t leng if (constant_id != 0) yp_parser_local_add(parser, constant_id); } +static inline bool +token_is_numbered_parameter(const uint8_t *start, const uint8_t *end) { + return (end - start == 2) && (start[0] == '_') && (start[1] != '0') && (yp_char_is_decimal_digit(start[1])); +} + // Add a parameter name to the current scope and check whether the name of the // parameter is unique or not. static void yp_parser_parameter_name_check(yp_parser_t *parser, yp_token_t *name) { + // We want to check whether the parameter name is a numbered parameter or not. + if (token_is_numbered_parameter(name->start, name->end)) { + yp_diagnostic_list_append(&parser->error_list, name->start, name->end, YP_ERR_PARAMETER_NUMBERED_RESERVED); + } + // We want to ignore any parameter name that starts with an underscore. if ((*name->start == '_')) return; @@ -4903,11 +4913,6 @@ char_is_global_name_punctuation(const uint8_t b) { } static inline bool -token_is_numbered_parameter(const uint8_t *start, const uint8_t *end) { - return (end - start == 2) && (start[0] == '_') && (start[1] != '0') && (yp_char_is_decimal_digit(start[1])); -} - -static inline bool token_is_setter_name(yp_token_t *token) { return ( (token->type == YP_TOKEN_IDENTIFIER) && @@ -12155,6 +12160,10 @@ parse_expression_prefix(yp_parser_t *parser, yp_binding_power_t binding_power) { yp_statements_node_t *statements = parse_statements(parser, YP_CONTEXT_PREEXE); expect1(parser, YP_TOKEN_BRACE_RIGHT, YP_ERR_BEGIN_UPCASE_TERM); + yp_context_t context = parser->current_context->context; + if ((context != YP_CONTEXT_MAIN) && (context != YP_CONTEXT_PREEXE)) { + yp_diagnostic_list_append(&parser->error_list, keyword.start, keyword.end, YP_ERR_BEGIN_UPCASE_TOPLEVEL); + } return (yp_node_t *) yp_pre_execution_node_create(parser, &keyword, &opening, statements, &parser->previous); } case YP_TOKEN_KEYWORD_BREAK: |