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

parse.y: warn assigned but unused in toplevel

* parse.y (local_push_gen): warn assigned but unused variables also in
  toplevel, except for -e option.  [Feature #7730] [ruby-core:51580]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38982 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-01-30 04:22:12 +00:00
parent 29707c1d73
commit 71eddb1dea
3 changed files with 9 additions and 1 deletions

View file

@ -1,3 +1,8 @@
Wed Jan 30 13:22:05 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (local_push_gen): warn assigned but unused variables also in
toplevel, except for -e option. [Feature #7730] [ruby-core:51580]
Wed Jan 30 13:17:53 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* cont.c (cont_restore_thread): svar should be separate per fibers.

View file

@ -9432,7 +9432,8 @@ local_push_gen(struct parser_params *parser, int inherit_dvars)
local->prev = lvtbl;
local->args = vtable_alloc(0);
local->vars = vtable_alloc(inherit_dvars ? DVARS_INHERIT : DVARS_TOPSCOPE);
local->used = !inherit_dvars && RTEST(ruby_verbose) ? vtable_alloc(0) : 0;
local->used = !(inherit_dvars && ifndef_ripper(e_option_supplied(parser))+0) &&
RTEST(ruby_verbose) ? vtable_alloc(0) : 0;
lvtbl = local;
}

View file

@ -551,6 +551,8 @@ class TestRubyOptions < Test::Unit::TestCase
assert_in_out_err(["-we", "def foo\n _a=1\nend"], "", [], [], feature6693)
bug7408 = '[ruby-core:49659]'
assert_in_out_err(["-we", "def foo\n a=1\n :a\nend"], "", [], ["-e:2: warning: assigned but unused variable - a"], bug7408)
feature7730 = '[ruby-core:51580]'
assert_in_out_err(["-w", "-"], "a=1", [], ["-:1: warning: assigned but unused variable - a"], feature7730)
end
def test_shadowing_variable