summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-23 13:00:27 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-23 13:00:27 +0000
commit08248c937caff193c277e8d3806f5c414dd2d2bf (patch)
tree56732be87b86c0252641baabbd5b231c15883e90
parent4f123ebd39a3b7dea34652626354c98da9c2f13c (diff)
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
-rw-r--r--ChangeLog10
-rw-r--r--parse.y2
-rw-r--r--test/ruby/test_keyword.rb14
3 files changed, 25 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index b5ece80c89..12919e092a 100644
--- a/ChangeLog
+++ b/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>
* tool/downloader.rb: added Downloader.download_if_modified_since
diff --git a/parse.y b/parse.y
index 45e09e0981..241e7f8fe3 100644
--- a/parse.y
+++ b/parse.y
@@ -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])
diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb
index 6080c02bf5..6e9cd2dbfe 100644
--- a/test/ruby/test_keyword.rb
+++ b/test/ruby/test_keyword.rb
@@ -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