@@ -9774,7 +9774,6 @@ parse_conditional(yp_parser_t *parser, yp_context_t context) {
9774
9774
case YP_TOKEN_KEYWORD_TRUE: case YP_TOKEN_KEYWORD_UNDEF: case YP_TOKEN_KEYWORD_UNLESS: case YP_TOKEN_KEYWORD_UNTIL: \
9775
9775
case YP_TOKEN_KEYWORD_WHEN: case YP_TOKEN_KEYWORD_WHILE: case YP_TOKEN_KEYWORD_YIELD
9776
9776
9777
-
9778
9777
// This macro allows you to define a case statement for all of the operators.
9779
9778
// It's meant to be used in a switch statement.
9780
9779
#define YP_CASE_OPERATOR YP_TOKEN_AMPERSAND: case YP_TOKEN_BACKTICK: case YP_TOKEN_BANG_EQUAL: \
@@ -10132,7 +10131,7 @@ parse_method_definition_name(yp_parser_t *parser) {
10132
10131
parser_lex(parser);
10133
10132
return parser->previous;
10134
10133
default:
10135
- return not_provided(parser) ;
10134
+ return (yp_token_t) { .type = YP_TOKEN_MISSING, .start = parser->current.start, .end = parser->current.end } ;
10136
10135
}
10137
10136
}
10138
10137
@@ -12032,7 +12031,7 @@ parse_expression_prefix(yp_parser_t *parser, yp_binding_power_t binding_power) {
12032
12031
12033
12032
yp_node_t *receiver = NULL;
12034
12033
yp_token_t operator = not_provided(parser);
12035
- yp_token_t name = not_provided(parser) ;
12034
+ yp_token_t name = (yp_token_t) { .type = YP_TOKEN_MISSING, .start = def_keyword.end, .end = def_keyword.end } ;
12036
12035
12037
12036
context_push(parser, YP_CONTEXT_DEF_PARAMS);
12038
12037
parser_lex(parser);
@@ -12056,10 +12055,6 @@ parse_expression_prefix(yp_parser_t *parser, yp_binding_power_t binding_power) {
12056
12055
12057
12056
operator = parser->previous;
12058
12057
name = parse_method_definition_name(parser);
12059
-
12060
- if (name.type == YP_TOKEN_MISSING) {
12061
- yp_diagnostic_list_append(&parser->error_list, parser->previous.start, parser->previous.end, YP_ERR_DEF_NAME_AFTER_RECEIVER);
12062
- }
12063
12058
} else {
12064
12059
yp_parser_scope_push(parser, true);
12065
12060
name = parser->previous;
@@ -12126,9 +12121,6 @@ parse_expression_prefix(yp_parser_t *parser, yp_binding_power_t binding_power) {
12126
12121
}
12127
12122
12128
12123
name = parse_method_definition_name(parser);
12129
- if (name.type == YP_TOKEN_MISSING) {
12130
- yp_diagnostic_list_append(&parser->error_list, parser->previous.start, parser->previous.end, YP_ERR_DEF_NAME_AFTER_RECEIVER);
12131
- }
12132
12124
} else {
12133
12125
name = identifier;
12134
12126
}
@@ -12155,13 +12147,15 @@ parse_expression_prefix(yp_parser_t *parser, yp_binding_power_t binding_power) {
12155
12147
default:
12156
12148
yp_parser_scope_push(parser, true);
12157
12149
name = parse_method_definition_name(parser);
12158
-
12159
- if (name.type == YP_TOKEN_MISSING) {
12160
- yp_diagnostic_list_append(&parser->error_list, parser->previous.start, parser->previous.end, YP_ERR_DEF_NAME);
12161
- }
12162
12150
break;
12163
12151
}
12164
12152
12153
+ // If, after all that, we were unable to find a method name, add an
12154
+ // error to the error list.
12155
+ if (name.type == YP_TOKEN_MISSING) {
12156
+ yp_diagnostic_list_append(&parser->error_list, parser->previous.start, parser->previous.end, YP_ERR_DEF_NAME);
12157
+ }
12158
+
12165
12159
yp_token_t lparen;
12166
12160
yp_token_t rparen;
12167
12161
yp_parameters_node_t *params;
0 commit comments