Skip to content

Commit

Permalink
parse.y: allow parenthesed do-block in cmdarg
Browse files Browse the repository at this point in the history
* parse.y (primary): flush cmdarg flags inside left-paren in a
  command argument, to allow parenthesed do-block as an argument
  without arguments parentheses.  [ruby-core:61950] [Bug #9726]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Apr 19, 2014
1 parent 95de2b0 commit c501345
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Sat Apr 19 15:38:29 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>

* parse.y (primary): flush cmdarg flags inside left-paren in a
command argument, to allow parenthesed do-block as an argument
without arguments parentheses. [ruby-core:61950] [Bug #9726]

Sat Apr 19 10:07:24 2014 Tanaka Akira <akr@fsij.org>

* internal.h (struct RBignum): Use size_t for len.
Expand Down
12 changes: 9 additions & 3 deletions parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -2620,12 +2620,18 @@ primary : literal
$$ = dispatch1(paren, 0);
%*/
}
| tLPAREN_ARG expr {lex_state = EXPR_ENDARG;} rparen
| tLPAREN_ARG
{
$<val>1 = cmdarg_stack;
cmdarg_stack = 0;
}
expr {lex_state = EXPR_ENDARG;} rparen
{
cmdarg_stack = $<val>1;
/*%%%*/
$$ = $2;
$$ = $3;
/*%
$$ = dispatch1(paren, $2);
$$ = dispatch1(paren, $3);
%*/
}
| tLPAREN compstmt ')'
Expand Down
5 changes: 5 additions & 0 deletions test/ruby/test_syntax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ def test_newline_in_block_parameters
end
end

def test_do_block_in_cmdarg
bug9726 = '[ruby-core:61950] [Bug #9726]'
assert_valid_syntax("tap (proc do end)", __FILE__, bug9726)
end

def test_keyword_rest
bug5989 = '[ruby-core:42455]'
assert_valid_syntax("def kwrest_test(**a) a; end", __FILE__, bug5989)
Expand Down

0 comments on commit c501345

Please sign in to comment.