From 20af032e82226d672d7d0f158a42e6118e8ee3fa Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 31 Jan 2013 07:33:30 +0000 Subject: [PATCH] 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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38998 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ parse.y | 3 ++- test/ruby/test_rubyoptions.rb | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index aa00dda6e4..91f3c06172 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Jan 31 16:33:27 2013 Nobuyoshi Nakada + + * 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 * test/ruby/test_signal.rb (test_trap_puts): Fix typo. "sync" diff --git a/parse.y b/parse.y index d950199f0b..2e81b66ab2 100644 --- a/parse.y +++ b/parse.y @@ -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 && 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; } diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index cf42475633..8f22bdaecc 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -554,6 +554,7 @@ class TestRubyOptions < Test::Unit::TestCase 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