Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -5286,7 +5286,7 @@ block_call : command do_block
| block_call call_op2 operation2 opt_paren_args brace_block
{
bool has_args = $5 != 0;
if (NODE_EMPTY_ARGS_P($5)) $5 = 0;
if (NODE_EMPTY_ARGS_P($4)) $4 = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is has_args $4 != 0 as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, probably no, has_args is misleading here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On current implementation, has_args has no meaning because brace_block ($5) is always evaluated to true. However I guess the ripper events for this rule might be wrong. Should it to be call!, method_add_arg! and method_add_block!?

Anyway I will merge this fix.

$$ = new_command_qcall(p, $2, $1, $3, $4, $5, &@3, &@$);
/*% ripper: command_call!($:1, $:2, $:3, $:4) %*/
if (has_args) {
Expand Down
4 changes: 4 additions & 0 deletions test/ruby/test_syntax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1829,6 +1829,10 @@ def test_command_semicolon_in_tlparen_at_the_first_arg
assert_valid_syntax('a.b (;),(),()', bug19281)
end

def test_command_do_block_call_with_empty_args_brace_block
assert_valid_syntax('cmd 1, 2 do end.m() { blk_body }')
end

def test_numbered_parameter
assert_valid_syntax('proc {_1}')
assert_equal(3, eval('[1,2].then {_1+_2}'))
Expand Down