Skip to content

Commit 943204d

Browse files
committed
Handle parsing local variable singleton method definition
1 parent 41430f4 commit 943204d

File tree

3 files changed

+60
-32
lines changed

3 files changed

+60
-32
lines changed

src/yarp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11806,12 +11806,12 @@ parse_expression_prefix(yp_parser_t *parser, yp_binding_power_t binding_power) {
1180611806
name = parser->previous;
1180711807
break;
1180811808
case YP_TOKEN_IDENTIFIER: {
11809-
yp_parser_scope_push(parser, true);
1181011809
parser_lex(parser);
1181111810

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

11814+
yp_parser_scope_push(parser, true);
1181511815
lex_state_set(parser, YP_LEX_STATE_FNAME);
1181611816
parser_lex(parser);
1181711817

@@ -11822,6 +11822,7 @@ parse_expression_prefix(yp_parser_t *parser, yp_binding_power_t binding_power) {
1182211822
yp_diagnostic_list_append(&parser->error_list, parser->previous.start, parser->previous.end, YP_ERR_DEF_NAME_AFTER_RECEIVER);
1182311823
}
1182411824
} else {
11825+
yp_parser_scope_push(parser, true);
1182511826
name = parser->previous;
1182611827
}
1182711828

test/yarp/fixtures/methods.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,6 @@ end
163163

164164
def foo(_a, _a, b, c)
165165
end
166+
167+
foo = 1
168+
def foo.bar; end

test/yarp/snapshots/methods.txt

Lines changed: 55 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)