1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-10-29 15:01:49 +00:00
parent 6fe9b2b794
commit 049bbd72e3
2 changed files with 12 additions and 0 deletions

View file

@ -3409,6 +3409,7 @@ opt_block_param : none
block_param_def : '|' opt_bv_decl '|' block_param_def : '|' opt_bv_decl '|'
{ {
current_arg = 0;
/*%%%*/ /*%%%*/
$$ = 0; $$ = 0;
/*% /*%
@ -3427,6 +3428,7 @@ block_param_def : '|' opt_bv_decl '|'
} }
| '|' block_param opt_bv_decl '|' | '|' block_param opt_bv_decl '|'
{ {
current_arg = 0;
/*%%%*/ /*%%%*/
$$ = $2; $$ = $2;
/*% /*%

View file

@ -171,6 +171,11 @@ class TestSyntax < Test::Unit::TestCase
assert_warn("") do assert_warn("") do
o.instance_eval("def foo(var: def bar(var) var; end) var end") o.instance_eval("def foo(var: def bar(var) var; end) var end")
end end
o = Object.new
assert_warn("") do
o.instance_eval("proc {|var: 1| var}")
end
end end
def test_optional_self_reference def test_optional_self_reference
@ -207,6 +212,11 @@ class TestSyntax < Test::Unit::TestCase
assert_warn("") do assert_warn("") do
o.instance_eval("def foo(var = def bar(var) var; end) var end") o.instance_eval("def foo(var = def bar(var) var; end) var end")
end end
o = Object.new
assert_warn("") do
o.instance_eval("proc {|var = 1| var}")
end
end end
def test_warn_grouped_expression def test_warn_grouped_expression