Permalink
Browse files

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...
1 parent 79f7dfa commit 9150340b9bcbe305c2647a8d6f6f8e754769f3e7 @nobu nobu committed Mar 21, 2013
Showing with 27 additions and 1 deletion.
  1. +5 −0 ChangeLog
  2. +1 −1 parse.y
  3. +21 −0 test/ruby/test_syntax.rb
View
@@ -1,3 +1,8 @@
+Fri Mar 22 05:30:49 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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@ruby-lang.org>
* vm_insnhelper.c (vm_callee_setup_keyword_arg): should check required
View
@@ -6786,7 +6786,7 @@ parser_prepare(struct parser_params *parser)
#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))
View
@@ -111,6 +111,27 @@ def test_warn_unreachable
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)

0 comments on commit 9150340

Please sign in to comment.