parse.y: label cannot be followed by a modifier

* parse.y (parse_ident): just after a label, new expression should
  start, cannot be a modifier.  [ruby-core:65211] [Bug #10279]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-09-23 13:00:27 +00:00
Родитель 4f123ebd39
Коммит 08248c937c
3 изменённых файлов: 25 добавлений и 1 удалений

Просмотреть файл

@ -1,3 +1,13 @@
Tue Sep 23 22:00:26 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (parse_ident): just after a label, new expression should
start, cannot be a modifier. [ruby-core:65211] [Bug #10279]
Tue Sep 23 22:00:20 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (parse_ident): just after a label, new expression should
start, cannot be a modifier. [ruby-core:65211] [Bug #10279]
Tue Sep 23 16:07:07 2014 Martin Duerst <duerst@it.aoyama.ac.jp>
* tool/downloader.rb: added Downloader.download_if_modified_since

Просмотреть файл

@ -7622,7 +7622,7 @@ parse_ident(struct parser_params *parser, int c, int cmd_state)
return keyword_do_block;
return keyword_do;
}
if (IS_lex_state_for(state, (EXPR_BEG | EXPR_VALUE)))
if (IS_lex_state_for(state, (EXPR_BEG | EXPR_VALUE | EXPR_LABELARG)))
return kw->id[0];
else {
if (kw->id[0] != kw->id[1])

Просмотреть файл

@ -325,7 +325,9 @@ class TestKeywordArguments < Test::Unit::TestCase
assert_equal([[:keyreq, :a], [:keyrest, :b]], o.method(:bar).parameters, feature7701)
assert_raise_with_message(ArgumentError, /missing keyword/, bug8139) {o.bar(c: bug8139)}
assert_raise_with_message(ArgumentError, /missing keyword/, bug8139) {o.bar}
end
def test_required_keyword_with_newline
bug9669 = '[ruby-core:61658] [Bug #9669]'
assert_nothing_raised(SyntaxError, bug9669) do
eval(<<-'end;', nil, __FILE__, __LINE__)
@ -335,6 +337,7 @@ class TestKeywordArguments < Test::Unit::TestCase
end;
end
assert_equal(42, bug9669.foo(a: 42))
o = nil
assert_nothing_raised(SyntaxError, bug9669) do
eval(<<-'end;', nil, __FILE__, __LINE__)
o = {
@ -346,6 +349,17 @@ class TestKeywordArguments < Test::Unit::TestCase
assert_equal({a: 1}, o, bug9669)
end
def test_required_keyword_with_reserved
bug10279 = '[ruby-core:65211] [Bug #10279]'
h = nil
assert_nothing_raised(SyntaxError, bug10279) do
break eval(<<-'end;', nil, __FILE__, __LINE__)
h = {a: if true then 42 end}
end;
end
assert_equal({a: 42}, h, bug10279)
end
def test_block_required_keyword
feature7701 = '[ruby-core:51454] [Feature #7701] required keyword argument'
b = assert_nothing_raised(SyntaxError, feature7701) do