Skip to content

Commit c501345

Browse files
committed
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
1 parent 95de2b0 commit c501345

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Sat Apr 19 15:38:29 2014 Nobuyoshi Nakada <[email protected]>
2+
3+
* parse.y (primary): flush cmdarg flags inside left-paren in a
4+
command argument, to allow parenthesed do-block as an argument
5+
without arguments parentheses. [ruby-core:61950] [Bug #9726]
6+
17
Sat Apr 19 10:07:24 2014 Tanaka Akira <[email protected]>
28

39
* internal.h (struct RBignum): Use size_t for len.

parse.y

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2620,12 +2620,18 @@ primary : literal
26202620
$$ = dispatch1(paren, 0);
26212621
%*/
26222622
}
2623-
| tLPAREN_ARG expr {lex_state = EXPR_ENDARG;} rparen
2623+
| tLPAREN_ARG
26242624
{
2625+
$<val>1 = cmdarg_stack;
2626+
cmdarg_stack = 0;
2627+
}
2628+
expr {lex_state = EXPR_ENDARG;} rparen
2629+
{
2630+
cmdarg_stack = $<val>1;
26252631
/*%%%*/
2626-
$$ = $2;
2632+
$$ = $3;
26272633
/*%
2628-
$$ = dispatch1(paren, $2);
2634+
$$ = dispatch1(paren, $3);
26292635
%*/
26302636
}
26312637
| tLPAREN compstmt ')'

test/ruby/test_syntax.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ def test_newline_in_block_parameters
7878
end
7979
end
8080

81+
def test_do_block_in_cmdarg
82+
bug9726 = '[ruby-core:61950] [Bug #9726]'
83+
assert_valid_syntax("tap (proc do end)", __FILE__, bug9726)
84+
end
85+
8186
def test_keyword_rest
8287
bug5989 = '[ruby-core:42455]'
8388
assert_valid_syntax("def kwrest_test(**a) a; end", __FILE__, bug5989)

0 commit comments

Comments
 (0)