[前][次][番号順一覧][スレッド一覧]

ruby-changes:26946

From: nobu <ko1@a...>
Date: Thu, 31 Jan 2013 16:33:44 +0900 (JST)
Subject: [ruby-changes:26946] nobu:r38998 (trunk): parse.y: no assigned but unused warnings in eval

nobu	2013-01-31 16:33:30 +0900 (Thu, 31 Jan 2013)

  New Revision: 38998

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38998

  Log:
    parse.y: no assigned but unused warnings in eval
    
    * parse.y (local_push_gen): no assigned but unused variable warnings
      in eval as well as -e.  [Feature #7730] [ruby-core:51580]

  Modified files:
    trunk/ChangeLog
    trunk/parse.y
    trunk/test/ruby/test_rubyoptions.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38997)
+++ ChangeLog	(revision 38998)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Jan 31 16:33:27 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* parse.y (local_push_gen): no assigned but unused variable warnings
+	  in eval as well as -e.  [Feature #7730] [ruby-core:51580]
+
 Wed Jan 30 12:30:08 2013  KOSAKI Motohiro  <kosaki.motohiro@g...>
 
 	* test/ruby/test_signal.rb (test_trap_puts): Fix typo. "sync"
Index: parse.y
===================================================================
--- parse.y	(revision 38997)
+++ parse.y	(revision 38998)
@@ -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 && ifndef_ripper(e_option_supplied(parser))+0) &&
+    local->used = !(inherit_dvars &&
+		    (ifndef_ripper(compile_for_eval || 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 38997)
+++ test/ruby/test_rubyoptions.rb	(revision 38998)
@@ -554,6 +554,7 @@ class TestRubyOptions < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyoptions.rb#L554
     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)
+    assert_in_out_err(["-w", "-"], "eval('a=1')", [], [], feature7730)
   end
 
   def test_shadowing_variable

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]