mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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:
parent
4f123ebd39
commit
08248c937c
3 changed files with 25 additions and 1 deletions
10
ChangeLog
10
ChangeLog
|
@ -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>
|
Tue Sep 23 16:07:07 2014 Martin Duerst <duerst@it.aoyama.ac.jp>
|
||||||
|
|
||||||
* tool/downloader.rb: added Downloader.download_if_modified_since
|
* tool/downloader.rb: added Downloader.download_if_modified_since
|
||||||
|
|
2
parse.y
2
parse.y
|
@ -7622,7 +7622,7 @@ parse_ident(struct parser_params *parser, int c, int cmd_state)
|
||||||
return keyword_do_block;
|
return keyword_do_block;
|
||||||
return keyword_do;
|
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];
|
return kw->id[0];
|
||||||
else {
|
else {
|
||||||
if (kw->id[0] != kw->id[1])
|
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_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(c: bug8139)}
|
||||||
assert_raise_with_message(ArgumentError, /missing keyword/, bug8139) {o.bar}
|
assert_raise_with_message(ArgumentError, /missing keyword/, bug8139) {o.bar}
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_required_keyword_with_newline
|
||||||
bug9669 = '[ruby-core:61658] [Bug #9669]'
|
bug9669 = '[ruby-core:61658] [Bug #9669]'
|
||||||
assert_nothing_raised(SyntaxError, bug9669) do
|
assert_nothing_raised(SyntaxError, bug9669) do
|
||||||
eval(<<-'end;', nil, __FILE__, __LINE__)
|
eval(<<-'end;', nil, __FILE__, __LINE__)
|
||||||
|
@ -335,6 +337,7 @@ class TestKeywordArguments < Test::Unit::TestCase
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
assert_equal(42, bug9669.foo(a: 42))
|
assert_equal(42, bug9669.foo(a: 42))
|
||||||
|
o = nil
|
||||||
assert_nothing_raised(SyntaxError, bug9669) do
|
assert_nothing_raised(SyntaxError, bug9669) do
|
||||||
eval(<<-'end;', nil, __FILE__, __LINE__)
|
eval(<<-'end;', nil, __FILE__, __LINE__)
|
||||||
o = {
|
o = {
|
||||||
|
@ -346,6 +349,17 @@ class TestKeywordArguments < Test::Unit::TestCase
|
||||||
assert_equal({a: 1}, o, bug9669)
|
assert_equal({a: 1}, o, bug9669)
|
||||||
end
|
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
|
def test_block_required_keyword
|
||||||
feature7701 = '[ruby-core:51454] [Feature #7701] required keyword argument'
|
feature7701 = '[ruby-core:51454] [Feature #7701] required keyword argument'
|
||||||
b = assert_nothing_raised(SyntaxError, feature7701) do
|
b = assert_nothing_raised(SyntaxError, feature7701) do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue