зеркало из https://github.com/github/ruby.git
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
This commit is contained in:
Родитель
79f7dfabb6
Коммит
9150340b9b
|
@ -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
|
||||
|
|
2
parse.y
2
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))
|
||||
|
|
|
@ -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)
|
||||
|
|
Загрузка…
Ссылка в новой задаче