Skip to content

Commit

Permalink
[Bug #19281] Allow semicolon in parenthesis at the first argument of …
Browse files Browse the repository at this point in the history
…command call
  • Loading branch information
yui-knk committed Aug 31, 2023
1 parent 0aa404b commit b35d22b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
9 changes: 1 addition & 8 deletions parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -3348,14 +3348,7 @@ primary : literal
/*% %*/
/*% ripper: begin!($3) %*/
}
| tLPAREN_ARG {SET_LEX_STATE(EXPR_ENDARG);} rparen
{
/*%%%*/
$$ = NEW_BEGIN(0, &@$);
/*% %*/
/*% ripper: paren!(0) %*/
}
| tLPAREN_ARG stmt {SET_LEX_STATE(EXPR_ENDARG);} rparen
| tLPAREN_ARG compstmt {SET_LEX_STATE(EXPR_ENDARG);} ')'
{
/*%%%*/
if (nd_type_p($2, NODE_SELF)) $2->nd_state = 0;
Expand Down
8 changes: 8 additions & 0 deletions test/ruby/test_syntax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1642,6 +1642,14 @@ def test_command_with_cmd_brace_block
assert_valid_syntax('obj::foo (1) {}')
end

def test_command_with_tlparen_arg_having_semicolon
bug19281 = '[ruby-core:111499] [Bug #19281]'
assert_valid_syntax('p (1;2),(3),(4)', bug19281)
assert_valid_syntax('p (;),(),()', bug19281)
assert_valid_syntax('a.b (1;2),(3),(4)', bug19281)
assert_valid_syntax('a.b (;),(),()', bug19281)
end

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

0 comments on commit b35d22b

Please sign in to comment.