diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-12-07 22:29:47 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-12-07 22:29:47 +0000 |
commit | 43cfe6c63edc7142aa3c0a361191bc8eec912d9d (patch) | |
tree | 339f2eb98e89ff68ff18a43774c445a6091e41e0 /test/ruby | |
parent | 7fd6016e1c3928d588e9bd7d787171f054674bd3 (diff) | |
download | ruby-43cfe6c63edc7142aa3c0a361191bc8eec912d9d.tar.gz |
* parse.y (struct vtable, struct local_vars, vtable_add):
restructued to add declared line. [ruby-dev:42718]
* parse.y (shadowing_lvar_gen): should not add dvar to vars.
* parse.y (local_push_gen, local_id_gen, dvar_defined_gen): check
local variable usage for args and vars respectedly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30124 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_rubyoptions.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index 9fad50ae4c..5a22fa0c9a 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -454,6 +454,21 @@ class TestRubyOptions < Test::Unit::TestCase assert_in_out_err(["-we", "def foo\n eval('a=1')\nend"], "", [], [], feature3446) assert_in_out_err(["-we", "1.times do\n a=1\nend"], "", [], [], feature3446) assert_in_out_err(["-we", "def foo\n 1.times do\n a=1\n end\nend"], "", [], ["-e:3: warning: assigned but unused variable - a"], feature3446) + bug4130 = '[ruby-dev:42718]' + assert_in_out_err(["-we", "def foo\n"" 1.times do |a| end\n""end"], "", [], + ["-e:2: warning: assigned but unused variable - a"], bug4130) + end + + def test_shadowing_variable + bug4130 = '[ruby-dev:42718]' + assert_in_out_err(["-we", "def foo\n"" a=1\n"" 1.times do |a| a; end\n"" a\n""end"], + "", [], ["-e:3: warning: shadowing outer local variable - a"], bug4130) + assert_in_out_err(["-we", "def foo\n"" a = 1\n"" 1.times do |a|\n"" end\n""end"], + "", [], + ["-e:3: warning: shadowing outer local variable - a", + "-e:3: warning: assigned but unused variable - a", + "-e:2: warning: assigned but unused variable - a", + ], bug4130) end def test_script_from_stdin |