[ruby/yarp] Constant paths followed by an & should be lexed as a call

https://github.com/ruby/yarp/commit/b0a2ba2c4d
This commit is contained in:
Kevin Newton 2023-08-23 14:09:15 -04:00 committed by git
parent cedb333063
commit f33c412ebc
3 changed files with 528 additions and 340 deletions

View File

@ -12,6 +12,18 @@ ABC
Foo 1
Foo *bar
Foo **bar
Foo &bar
Foo::Bar *baz
Foo::Bar **baz
Foo::Bar &baz
::A::foo
::A = 1

File diff suppressed because it is too large Load Diff

View File

@ -10223,7 +10223,7 @@ parse_expression_prefix(yp_parser_t *parser, yp_binding_power_t binding_power) {
// fact a method call, not a constant read.
if (
match_type_p(parser, YP_TOKEN_PARENTHESIS_LEFT) ||
(binding_power <= YP_BINDING_POWER_ASSIGNMENT && (token_begins_expression_p(parser->current.type) || match_any_type_p(parser, 2, YP_TOKEN_USTAR, YP_TOKEN_USTAR_STAR))) ||
(binding_power <= YP_BINDING_POWER_ASSIGNMENT && (token_begins_expression_p(parser->current.type) || match_any_type_p(parser, 3, YP_TOKEN_UAMPERSAND, YP_TOKEN_USTAR, YP_TOKEN_USTAR_STAR))) ||
(yp_accepts_block_stack_p(parser) && match_any_type_p(parser, 2, YP_TOKEN_KEYWORD_DO, YP_TOKEN_BRACE_LEFT))
) {
yp_arguments_t arguments = YP_EMPTY_ARGUMENTS;
@ -10346,7 +10346,7 @@ parse_expression_prefix(yp_parser_t *parser, yp_binding_power_t binding_power) {
// can still be a method call if it is followed by arguments or
// a block, so we need to check for that here.
if (
(binding_power <= YP_BINDING_POWER_ASSIGNMENT && (token_begins_expression_p(parser->current.type) || match_any_type_p(parser, 2, YP_TOKEN_USTAR, YP_TOKEN_USTAR_STAR))) ||
(binding_power <= YP_BINDING_POWER_ASSIGNMENT && (token_begins_expression_p(parser->current.type) || match_any_type_p(parser, 3, YP_TOKEN_UAMPERSAND, YP_TOKEN_USTAR, YP_TOKEN_USTAR_STAR))) ||
(yp_accepts_block_stack_p(parser) && match_any_type_p(parser, 2, YP_TOKEN_KEYWORD_DO, YP_TOKEN_BRACE_LEFT))
) {
yp_arguments_t arguments = YP_EMPTY_ARGUMENTS;
@ -12518,7 +12518,7 @@ parse_expression_infix(yp_parser_t *parser, yp_node_t *node, yp_binding_power_t
if (
(parser->current.type == YP_TOKEN_PARENTHESIS_LEFT) ||
(token_begins_expression_p(parser->current.type) || match_any_type_p(parser, 2, YP_TOKEN_USTAR, YP_TOKEN_USTAR_STAR))
(token_begins_expression_p(parser->current.type) || match_any_type_p(parser, 3, YP_TOKEN_UAMPERSAND, YP_TOKEN_USTAR, YP_TOKEN_USTAR_STAR))
) {
// If we have a constant immediately following a '::' operator, then
// this can either be a constant path or a method call, depending on