summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--parse.y2
-rw-r--r--test/ruby/test_syntax.rb21
3 files changed, 27 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 1cea895a29..d513220f87 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/parse.y b/parse.y
index 7399aa9c25..0f0fbe8346 100644
--- a/parse.y
+++ b/parse.y
@@ -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))
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index bc29007359..823b64692c 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -111,6 +111,27 @@ class TestSyntax < Test::Unit::TestCase
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)