Skip to content

Commit

Permalink
Merge pull request #3119 from eileencodes/fix-3112
Browse files Browse the repository at this point in the history
Fix 3112 - disallow commas after block arg
  • Loading branch information
kddnewton authored Oct 1, 2024
2 parents b44616d + 544df58 commit 3eacea4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/prism.c
Original file line number Diff line number Diff line change
Expand Up @@ -14127,9 +14127,6 @@ parse_arguments(pm_parser_t *parser, pm_arguments_t *arguments, bool accepts_for
bool parsed_forwarding_arguments = false;

while (!match1(parser, PM_TOKEN_EOF)) {
if (parsed_block_argument) {
pm_parser_err_current(parser, PM_ERR_ARGUMENT_AFTER_BLOCK);
}
if (parsed_forwarding_arguments) {
pm_parser_err_current(parser, PM_ERR_ARGUMENT_AFTER_FORWARDING_ELLIPSES);
}
Expand Down Expand Up @@ -14178,6 +14175,10 @@ parse_arguments(pm_parser_t *parser, pm_arguments_t *arguments, bool accepts_for
arguments->block = argument;
}

if (match1(parser, PM_TOKEN_COMMA)) {
pm_parser_err_current(parser, PM_ERR_ARGUMENT_AFTER_BLOCK);
}

parsed_block_argument = true;
break;
}
Expand Down
16 changes: 15 additions & 1 deletion test/prism/errors/arguments_after_block.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
a(&block, foo)
^~~ unexpected argument after a block argument
^ unexpected argument after a block argument
a(&block,)
^ unexpected argument after a block argument
a.(&block,)
^ unexpected argument after a block argument
a[&block,]
^ unexpected argument after a block argument
def a(&block)
p(&block,)
^ unexpected argument after a block argument
a.(&block,)
^ unexpected argument after a block argument
a[&block,]
^ unexpected argument after a block argument
end

0 comments on commit 3eacea4

Please sign in to comment.