ruby-changes:27818
From: nobu <ko1@a...>
Date: Fri, 22 Mar 2013 05:31:05 +0900 (JST)
Subject: [ruby-changes:27818] nobu:r39870 (trunk): parse.y: refine warning message
nobu 2013-03-22 05:30:53 +0900 (Fri, 22 Mar 2013) New Revision: 39870 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39870 Log: parse.y: refine warning message * parse.y (ambiguous_operator): refine warning message, since this warning is shown after literal too. Modified files: trunk/ChangeLog trunk/parse.y trunk/test/ruby/test_syntax.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 39869) +++ ChangeLog (revision 39870) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Mar 22 05:30:49 2013 Nobuyoshi Nakada <nobu@r...> + + * parse.y (ambiguous_operator): refine warning message, since this + warning is shown after literal too. + Fri Mar 22 04:51:14 2013 Nobuyoshi Nakada <nobu@r...> * vm_insnhelper.c (vm_callee_setup_keyword_arg): should check required Index: parse.y =================================================================== --- parse.y (revision 39869) +++ parse.y (revision 39870) @@ -6786,7 +6786,7 @@ parser_prepare(struct parser_params *par https://github.com/ruby/ruby/blob/trunk/parse.y#L6786 #ifndef RIPPER #define ambiguous_operator(op, syn) ( \ - rb_warning0("`"op"' after local variable is interpreted as binary operator"), \ + rb_warning0("`"op"' after local variable or literal is interpreted as binary operator"), \ rb_warning0("even though it seems like "syn"")) #else #define ambiguous_operator(op, syn) dispatch2(operator_ambiguous, ripper_intern(op), rb_str_new_cstr(syn)) Index: test/ruby/test_syntax.rb =================================================================== --- test/ruby/test_syntax.rb (revision 39869) +++ test/ruby/test_syntax.rb (revision 39870) @@ -111,6 +111,27 @@ class TestSyntax < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L111 end end + def test_warn_balanced + warning = <<WARN +test:1: warning: `%s' after local variable or literal is interpreted as binary operator +test:1: warning: even though it seems like %s +WARN + [ + [:**, "argument prefix"], + [:*, "argument prefix"], + [:<<, "here document"], + [:&, "argument prefix"], + [:+, "unary operator"], + [:-, "unary operator"], + [:/, "regexp literal"], + [:%, "string literal"], + ].each do |op, syn| + assert_warning(warning % [op, syn]) do + assert_valid_syntax("puts 1 #{op}0", "test") {$VERBOSE = true} + end + end + end + def test_cmd_symbol_after_keyword bug6347 = '[ruby-dev:45563]' assert_not_label(:foo, 'if true then not_label:foo end', bug6347) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/