ruby-changes:26930
From: nobu <ko1@a...>
Date: Wed, 30 Jan 2013 13:22:22 +0900 (JST)
Subject: [ruby-changes:26930] nobu:r38982 (trunk): parse.y: warn assigned but unused in toplevel
nobu 2013-01-30 13:22:12 +0900 (Wed, 30 Jan 2013) New Revision: 38982 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38982 Log: 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] Modified files: trunk/ChangeLog trunk/parse.y trunk/test/ruby/test_rubyoptions.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 38981) +++ ChangeLog (revision 38982) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Jan 30 13:22:05 2013 Nobuyoshi Nakada <nobu@r...> + + * 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@r...> * cont.c (cont_restore_thread): svar should be separate per fibers. Index: parse.y =================================================================== --- parse.y (revision 38981) +++ parse.y (revision 38982) @@ -9432,7 +9432,8 @@ local_push_gen(struct parser_params *par https://github.com/ruby/ruby/blob/trunk/parse.y#L9432 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; } Index: test/ruby/test_rubyoptions.rb =================================================================== --- test/ruby/test_rubyoptions.rb (revision 38981) +++ test/ruby/test_rubyoptions.rb (revision 38982) @@ -551,6 +551,8 @@ class TestRubyOptions < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyoptions.rb#L551 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/