[前][次][番号順一覧][スレッド一覧]

ruby-changes:35614

From: nobu <ko1@a...>
Date: Tue, 23 Sep 2014 22:00:43 +0900 (JST)
Subject: [ruby-changes:35614] nobu:r47696 (trunk): parse.y: label cannot be followed by a modifier

nobu	2014-09-23 22:00:27 +0900 (Tue, 23 Sep 2014)

  New Revision: 47696

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47696

  Log:
    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]

  Modified files:
    trunk/ChangeLog
    trunk/parse.y
    trunk/test/ruby/test_keyword.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 47695)
+++ ChangeLog	(revision 47696)
@@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Sep 23 22:00:26 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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@r...>
+
+	* 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@i...>
 
 	* tool/downloader.rb: added Downloader.download_if_modified_since
Index: parse.y
===================================================================
--- parse.y	(revision 47695)
+++ parse.y	(revision 47696)
@@ -7622,7 +7622,7 @@ parse_ident(struct parser_params *parser https://github.com/ruby/ruby/blob/trunk/parse.y#L7622
 		    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])
Index: test/ruby/test_keyword.rb
===================================================================
--- test/ruby/test_keyword.rb	(revision 47695)
+++ test/ruby/test_keyword.rb	(revision 47696)
@@ -325,7 +325,9 @@ class TestKeywordArguments < Test::Unit: https://github.com/ruby/ruby/blob/trunk/test/ruby/test_keyword.rb#L325
     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: https://github.com/ruby/ruby/blob/trunk/test/ruby/test_keyword.rb#L337
       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: https://github.com/ruby/ruby/blob/trunk/test/ruby/test_keyword.rb#L349
     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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]