ruby-changes:22864
From: nobu <ko1@a...>
Date: Tue, 6 Mar 2012 01:34:31 +0900 (JST)
Subject: [ruby-changes:22864] nobu:r34913 (trunk): * parse.y (block_call): rules for block_call after block_call.
nobu 2012-03-06 01:34:21 +0900 (Tue, 06 Mar 2012) New Revision: 34913 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34913 Log: * parse.y (block_call): rules for block_call after block_call. based on a patch by pasberth https://github.com/ruby/ruby/pull/102 [ruby-dev:45308][Bug #6115] Modified files: trunk/ChangeLog trunk/parse.y trunk/test/ruby/test_syntax.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 34912) +++ ChangeLog (revision 34913) @@ -1,3 +1,9 @@ +Tue Mar 6 01:34:19 2012 Nobuyoshi Nakada <nobu@r...> + + * parse.y (block_call): rules for block_call after block_call. + based on a patch by pasberth https://github.com/ruby/ruby/pull/102 + [ruby-dev:45308][Bug #6115] + Tue Mar 6 01:24:13 2012 Nobuyoshi Nakada <nobu@r...> * parse.y (block_command, block_call): simplified rules. Index: parse.y =================================================================== --- parse.y (revision 34912) +++ parse.y (revision 34913) @@ -3856,6 +3856,30 @@ $$ = method_optarg($$, $4); %*/ } + | block_call dot_or_colon operation2 opt_paren_args brace_block + { + /*%%%*/ + block_dup_check($4, $5); + $5->nd_iter = NEW_CALL($1, $3, $4); + $$ = $5; + fixpos($$, $1); + /*% + $$ = dispatch4(command_call, $1, $2, $3, $4); + $$ = method_add_block($$, $5); + %*/ + } + | block_call dot_or_colon operation2 command_args do_block + { + /*%%%*/ + block_dup_check($4, $5); + $5->nd_iter = NEW_CALL($1, $3, $4); + $$ = $5; + fixpos($$, $1); + /*% + $$ = dispatch4(command_call, $1, $2, $3, $4); + $$ = method_add_block($$, $5); + %*/ + } ; method_call : operation Index: test/ruby/test_syntax.rb =================================================================== --- test/ruby/test_syntax.rb (revision 34912) +++ test/ruby/test_syntax.rb (revision 34913) @@ -63,6 +63,20 @@ end end + tap do |_, + bug6115 = '[ruby-dev:45308]', + blockcall = '["elem"].each_with_object [] do end', + methods = [['map', 'no'], ['inject([])', 'with']], + blocks = [['do end', 'do'], ['{}', 'brace']], + *| + [%w'. dot', %w':: colon'].product(methods, blocks) do |(c, n1), (m, n2), (b, n3)| + m = m.tr_s('()', ' ').strip if n2 == 'do' + name = "test_#{n3}_block_after_blockcall_#{n1}_#{n2}_arg" + code = "#{blockcall}#{c}#{m} #{b}" + define_method(name) {assert_valid_syntax(code, bug6115)} + end + end + private def make_tmpsrc(f, src) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/