Skip to content

Commit 8ca24f2

Browse files
committed
Fix prism brace association for constant-like method/local calls
1 parent 5f46d36 commit 8ca24f2

File tree

3 files changed

+118
-50
lines changed

3 files changed

+118
-50
lines changed

src/prism.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14314,7 +14314,8 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power, b
1431414314
if (
1431514315
match1(parser, PM_TOKEN_PARENTHESIS_LEFT) ||
1431614316
(accepts_command_call && (token_begins_expression_p(parser->current.type) || match3(parser, PM_TOKEN_UAMPERSAND, PM_TOKEN_USTAR, PM_TOKEN_USTAR_STAR))) ||
14317-
(pm_accepts_block_stack_p(parser) && match2(parser, PM_TOKEN_KEYWORD_DO, PM_TOKEN_BRACE_LEFT))
14317+
(pm_accepts_block_stack_p(parser) && match1(parser, PM_TOKEN_KEYWORD_DO)) ||
14318+
match1(parser, PM_TOKEN_BRACE_LEFT)
1431814319
) {
1431914320
pm_arguments_t arguments = { 0 };
1432014321
parse_arguments_list(parser, &arguments, true, accepts_command_call);
@@ -14438,7 +14439,8 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power, b
1443814439
// a block, so we need to check for that here.
1443914440
if (
1444014441
(accepts_command_call && (token_begins_expression_p(parser->current.type) || match3(parser, PM_TOKEN_UAMPERSAND, PM_TOKEN_USTAR, PM_TOKEN_USTAR_STAR))) ||
14441-
(pm_accepts_block_stack_p(parser) && match2(parser, PM_TOKEN_KEYWORD_DO, PM_TOKEN_BRACE_LEFT))
14442+
(pm_accepts_block_stack_p(parser) && match1(parser, PM_TOKEN_KEYWORD_DO)) ||
14443+
match1(parser, PM_TOKEN_BRACE_LEFT)
1444214444
) {
1444314445
pm_arguments_t arguments = { 0 };
1444414446
parse_arguments_list(parser, &arguments, true, accepts_command_call);

test/prism/fixtures/method_calls.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,8 @@ lst << A {}
147147
"#{(v)}"
148148

149149
def f(*); p *; end
150+
151+
foo 1, Bar { 1 }
152+
153+
foo = 1
154+
foo {}

test/prism/snapshots/method_calls.txt

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

0 commit comments

Comments
 (0)