Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

parse.y: refine warning message

* parse.y (ambiguous_operator): refine warning message, since this
  warning is shown after literal too.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
commit 9150340b9bcbe305c2647a8d6f6f8e754769f3e7 1 parent 79f7dfa
Nobuyoshi Nakada authored March 21, 2013
5  ChangeLog
... ...
@@ -1,3 +1,8 @@
  1
+Fri Mar 22 05:30:49 2013  Nobuyoshi Nakada  <nobu@ruby-lang.org>
  2
+
  3
+	* parse.y (ambiguous_operator): refine warning message, since this
  4
+	  warning is shown after literal too.
  5
+
1 6
 Fri Mar 22 04:51:14 2013  Nobuyoshi Nakada  <nobu@ruby-lang.org>
2 7
 
3 8
 	* vm_insnhelper.c (vm_callee_setup_keyword_arg): should check required
2  parse.y
@@ -6786,7 +6786,7 @@ parser_prepare(struct parser_params *parser)
6786 6786
 
6787 6787
 #ifndef RIPPER
6788 6788
 #define ambiguous_operator(op, syn) ( \
6789  
-    rb_warning0("`"op"' after local variable is interpreted as binary operator"), \
  6789
+    rb_warning0("`"op"' after local variable or literal is interpreted as binary operator"), \
6790 6790
     rb_warning0("even though it seems like "syn""))
6791 6791
 #else
6792 6792
 #define ambiguous_operator(op, syn) dispatch2(operator_ambiguous, ripper_intern(op), rb_str_new_cstr(syn))
21  test/ruby/test_syntax.rb
@@ -111,6 +111,27 @@ def test_warn_unreachable
111 111
     end
112 112
   end
113 113
 
  114
+  def test_warn_balanced
  115
+    warning = <<WARN
  116
+test:1: warning: `%s' after local variable or literal is interpreted as binary operator
  117
+test:1: warning: even though it seems like %s
  118
+WARN
  119
+    [
  120
+     [:**, "argument prefix"],
  121
+     [:*, "argument prefix"],
  122
+     [:<<, "here document"],
  123
+     [:&, "argument prefix"],
  124
+     [:+, "unary operator"],
  125
+     [:-, "unary operator"],
  126
+     [:/, "regexp literal"],
  127
+     [:%, "string literal"],
  128
+    ].each do |op, syn|
  129
+      assert_warning(warning % [op, syn]) do
  130
+        assert_valid_syntax("puts 1 #{op}0", "test") {$VERBOSE = true}
  131
+      end
  132
+    end
  133
+  end
  134
+
114 135
   def test_cmd_symbol_after_keyword
115 136
     bug6347 = '[ruby-dev:45563]'
116 137
     assert_not_label(:foo, 'if true then not_label:foo end', bug6347)

0 notes on commit 9150340

Please sign in to comment.
Something went wrong with that request. Please try again.