зеркало из https://github.com/github/ruby.git
* parse.y (parser_yylex): fix warning line number.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35038 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
b30c4aa8d7
Коммит
bf87ec4eb9
|
@ -1,3 +1,7 @@
|
|||
Thu Mar 15 15:37:42 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* parse.y (parser_yylex): fix warning line number.
|
||||
|
||||
Thu Mar 15 15:19:38 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* enumerator.c (lazy_cycle): check argument number overflow before
|
||||
|
|
2
parse.y
2
parse.y
|
@ -2694,7 +2694,6 @@ primary : literal
|
|||
}
|
||||
| tLPAREN_ARG expr {lex_state = EXPR_ENDARG;} rparen
|
||||
{
|
||||
rb_warning0("(...) interpreted as grouped expression");
|
||||
/*%%%*/
|
||||
$$ = $2;
|
||||
/*%
|
||||
|
@ -7617,6 +7616,7 @@ parser_yylex(struct parser_params *parser)
|
|||
}
|
||||
else if (IS_SPCARG(-1)) {
|
||||
c = tLPAREN_ARG;
|
||||
rb_warning0("(...) interpreted as grouped expression");
|
||||
}
|
||||
paren_nest++;
|
||||
COND_PUSH(0);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
require 'test/unit'
|
||||
require_relative 'envutil'
|
||||
|
||||
class TestSyntax < Test::Unit::TestCase
|
||||
def assert_valid_syntax(code, fname, mesg = fname)
|
||||
|
@ -8,6 +9,7 @@ class TestSyntax < Test::Unit::TestCase
|
|||
}
|
||||
code.force_encoding("us-ascii")
|
||||
verbose, $VERBOSE = $VERBOSE, nil
|
||||
yield if defined?(yield)
|
||||
assert_nothing_raised(SyntaxError, mesg) do
|
||||
assert_equal(:ok, catch {|tag| eval(code, binding, fname, 0)}, mesg)
|
||||
end
|
||||
|
@ -88,6 +90,12 @@ class TestSyntax < Test::Unit::TestCase
|
|||
assert_equal({foo: 1, bar: 2}, o.kw(foo: 1, bar: 2))
|
||||
end
|
||||
|
||||
def test_warn_grouped_expression
|
||||
assert_warn("test:2: warning: (...) interpreted as grouped expression\n") do
|
||||
assert_valid_syntax("foo \\\n(\n true)", "test") {$VERBOSE = true}
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def make_tmpsrc(f, src)
|
||||
|
|
Загрузка…
Ссылка в новой задаче