ruby-changes:36109
From: nobu <ko1@a...>
Date: Thu, 30 Oct 2014 00:02:00 +0900 (JST)
Subject: [ruby-changes:36109] nobu:r48190 (trunk): parse.y: reset current_arg after block var
nobu 2014-10-30 00:01:49 +0900 (Thu, 30 Oct 2014) New Revision: 48190 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48190 Log: parse.y: reset current_arg after block var * parse.y (block_param_def): reset current_arg after block parameter definition, not to warn references in that block body. [ruby-core:65990] [Bug #10314] Modified files: trunk/parse.y trunk/test/ruby/test_syntax.rb Index: parse.y =================================================================== --- parse.y (revision 48189) +++ parse.y (revision 48190) @@ -3409,6 +3409,7 @@ opt_block_param : none https://github.com/ruby/ruby/blob/trunk/parse.y#L3409 block_param_def : '|' opt_bv_decl '|' { + current_arg = 0; /*%%%*/ $$ = 0; /*% @@ -3427,6 +3428,7 @@ block_param_def : '|' opt_bv_decl '|' https://github.com/ruby/ruby/blob/trunk/parse.y#L3428 } | '|' block_param opt_bv_decl '|' { + current_arg = 0; /*%%%*/ $$ = $2; /*% Index: test/ruby/test_syntax.rb =================================================================== --- test/ruby/test_syntax.rb (revision 48189) +++ test/ruby/test_syntax.rb (revision 48190) @@ -171,6 +171,11 @@ class TestSyntax < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L171 assert_warn("") do o.instance_eval("def foo(var: def bar(var) var; end) var end") end + + o = Object.new + assert_warn("") do + o.instance_eval("proc {|var: 1| var}") + end end def test_optional_self_reference @@ -207,6 +212,11 @@ class TestSyntax < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L212 assert_warn("") do o.instance_eval("def foo(var = def bar(var) var; end) var end") end + + o = Object.new + assert_warn("") do + o.instance_eval("proc {|var = 1| var}") + end end def test_warn_grouped_expression -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/