mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parse.y: allow parenthesed do-block in cmdarg
* 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
This commit is contained in:
parent
95de2b0012
commit
c501345218
3 changed files with 20 additions and 3 deletions
|
@ -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.
|
||||
|
|
12
parse.y
12
parse.y
|
@ -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 ')'
|
||||
|
|
|
@ -78,6 +78,11 @@ class TestSyntax < Test::Unit::TestCase
|
|||
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)
|
||||
|
|
Loading…
Reference in a new issue