ruby-changes:13290
From: nobu <ko1@a...>
Date: Wed, 23 Sep 2009 17:08:49 +0900 (JST)
Subject: [ruby-changes:13290] Ruby:r25053 (trunk): * parse.y (assign_in_cond): also should warn assignment to dvar in
nobu 2009-09-23 17:08:32 +0900 (Wed, 23 Sep 2009) New Revision: 25053 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25053 Log: * parse.y (assign_in_cond): also should warn assignment to dvar in conditional. [ruby-dev:39363] Modified files: trunk/ChangeLog trunk/parse.y trunk/test/ruby/test_rubyoptions.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 25052) +++ ChangeLog (revision 25053) @@ -1,3 +1,8 @@ +Wed Sep 23 17:08:30 2009 Nobuyoshi Nakada <nobu@r...> + + * parse.y (assign_in_cond): also should warn assignment to dvar in + conditional. [ruby-dev:39363] + Wed Sep 23 13:14:21 2009 Nobuyoshi Nakada <nobu@r...> * string.c (rb_str_upto): keep first width. [ruby-dev:39361] Index: parse.y =================================================================== --- parse.y (revision 25052) +++ parse.y (revision 25053) @@ -8463,6 +8463,7 @@ case NODE_LASGN: case NODE_DASGN: + case NODE_DASGN_CURR: case NODE_GASGN: case NODE_IASGN: break; Index: test/ruby/test_rubyoptions.rb =================================================================== --- test/ruby/test_rubyoptions.rb (revision 25052) +++ test/ruby/test_rubyoptions.rb (revision 25053) @@ -281,13 +281,33 @@ /invalid name for global variable - -# \(NameError\)/) end + def test_assignment_in_conditional + t = Tempfile.new(["test_ruby_test_rubyoption", ".rb"]) + t.puts "if a = 1" + t.puts "end" + t.puts "0.times do" + t.puts " if b = 2" + t.puts " end" + t.puts "end" + t.close + err = ["#{t.path}:1: warning: found = in conditional, should be ==", + "#{t.path}:4: warning: found = in conditional, should be =="] + err = /\A(#{Regexp.quote(t.path)}):1(: warning: found = in conditional, should be ==)\n\1:4\2\Z/ + bug2136 = '[ruby-dev:39363]' + assert_in_out_err(["-w", t.path], "", [], err, bug2136) + assert_in_out_err(["-wr", t.path, "-e", ""], "", [], err, bug2136) + ensure + t.close(true) if t + end + def test_indentation_check t = Tempfile.new(["test_ruby_test_rubyoption", ".rb"]) t.puts "begin" t.puts " end" t.close - assert_in_out_err(["-w", t.path], "", [], /:2: warning: mismatched indentations at 'end' with 'begin' at 1/) - assert_in_out_err(["-wr", t.path, "-e", ""], "", [], /:2: warning: mismatched indentations at 'end' with 'begin' at 1/) + err = ["#{t.path}:2: warning: mismatched indentations at 'end' with 'begin' at 1"] + assert_in_out_err(["-w", t.path], "", [], err) + assert_in_out_err(["-wr", t.path, "-e", ""], "", [], err) ensure t.close(true) if t end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/