Skip to content

Commit

Permalink
Handle parsing local variable singleton method definition
Browse files Browse the repository at this point in the history
  • Loading branch information
kddnewton committed Sep 13, 2023
1 parent 41430f4 commit 943204d
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 32 deletions.
3 changes: 2 additions & 1 deletion src/yarp.c
Original file line number Diff line number Diff line change
Expand Up @@ -11806,12 +11806,12 @@ parse_expression_prefix(yp_parser_t *parser, yp_binding_power_t binding_power) {
name = parser->previous;
break;
case YP_TOKEN_IDENTIFIER: {
yp_parser_scope_push(parser, true);
parser_lex(parser);

if (match_any_type_p(parser, 2, YP_TOKEN_DOT, YP_TOKEN_COLON_COLON)) {
receiver = parse_variable_call(parser);

yp_parser_scope_push(parser, true);
lex_state_set(parser, YP_LEX_STATE_FNAME);
parser_lex(parser);

Expand All @@ -11822,6 +11822,7 @@ parse_expression_prefix(yp_parser_t *parser, yp_binding_power_t binding_power) {
yp_diagnostic_list_append(&parser->error_list, parser->previous.start, parser->previous.end, YP_ERR_DEF_NAME_AFTER_RECEIVER);
}
} else {
yp_parser_scope_push(parser, true);
name = parser->previous;
}

Expand Down
3 changes: 3 additions & 0 deletions test/yarp/fixtures/methods.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,6 @@ end

def foo(_a, _a, b, c)
end

foo = 1
def foo.bar; end
86 changes: 55 additions & 31 deletions test/yarp/snapshots/methods.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 943204d

Please sign in to comment.