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

ruby-changes:27656

From: nagachika <ko1@a...>
Date: Mon, 11 Mar 2013 01:13:14 +0900 (JST)
Subject: [ruby-changes:27656] nagachika:r39708 (ruby_2_0_0): merge revision(s) 39504: [Backport #7942]

nagachika	2013-03-11 01:13:04 +0900 (Mon, 11 Mar 2013)

  New Revision: 39708

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

  Log:
    merge revision(s) 39504: [Backport #7942]
    
    * parse.y (IS_LABEL_POSSIBLE): allow labels for keyword arguments just
      after method definition without a parenthesis.  [ruby-core:52820]
      [Bug #7942]

  Modified directories:
    branches/ruby_2_0_0/
  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/parse.y
    branches/ruby_2_0_0/test/ruby/test_keyword.rb
    branches/ruby_2_0_0/version.h

Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 39707)
+++ ruby_2_0_0/ChangeLog	(revision 39708)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Mon Mar 11 01:12:50 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* parse.y (IS_LABEL_POSSIBLE): allow labels for keyword arguments just
+	  after method definition without a parenthesis.  [ruby-core:52820]
+	  [Bug #7942]
+
 Mon Mar 11 01:09:23 2013  Zachary Scott  <zachary@z...>
 
 	* error.c: clarify reason for sleep in SignalException example
Index: ruby_2_0_0/parse.y
===================================================================
--- ruby_2_0_0/parse.y	(revision 39707)
+++ ruby_2_0_0/parse.y	(revision 39708)
@@ -6760,7 +6760,7 @@ parser_prepare(struct parser_params *par https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/parse.y#L6760
 #define IS_END() IS_lex_state(EXPR_END_ANY)
 #define IS_BEG() IS_lex_state(EXPR_BEG_ANY)
 #define IS_SPCARG(c) (IS_ARG() && space_seen && !ISSPACE(c))
-#define IS_LABEL_POSSIBLE() ((IS_lex_state(EXPR_BEG) && !cmd_state) || IS_ARG())
+#define IS_LABEL_POSSIBLE() ((IS_lex_state(EXPR_BEG | EXPR_ENDFN) && !cmd_state) || IS_ARG())
 #define IS_LABEL_SUFFIX(n) (peek_n(':',(n)) && !peek_n(':', (n)+1))
 #define IS_AFTER_OPERATOR() IS_lex_state(EXPR_FNAME | EXPR_DOT)
 
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 39707)
+++ ruby_2_0_0/version.h	(revision 39708)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
 #define RUBY_RELEASE_DATE "2013-03-11"
-#define RUBY_PATCHLEVEL 52
+#define RUBY_PATCHLEVEL 53
 
 #define RUBY_RELEASE_YEAR 2013
 #define RUBY_RELEASE_MONTH 3
Index: ruby_2_0_0/test/ruby/test_keyword.rb
===================================================================
--- ruby_2_0_0/test/ruby/test_keyword.rb	(revision 39707)
+++ ruby_2_0_0/test/ruby/test_keyword.rb	(revision 39708)
@@ -274,4 +274,20 @@ class TestKeywordArguments < Test::Unit: https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_keyword.rb#L274
     assert_valid_syntax("def bug7662(*, **) end")
     assert_valid_syntax("def bug7662(a, **) end")
   end
+
+  def test_without_paren
+    bug7942 = '[ruby-core:52820] [Bug #7942]'
+    assert_valid_syntax("def bug7942 a: 1; end")
+    assert_valid_syntax("def bug7942 a: 1, **; end")
+
+    o = Object.new
+    eval("def o.bug7942 a: 1; a; end", nil, __FILE__, __LINE__)
+    assert_equal(1, o.bug7942(), bug7942)
+    assert_equal(42, o.bug7942(a: 42), bug7942)
+
+    o = Object.new
+    eval("def o.bug7942 a: 1, **; a; end", nil, __FILE__, __LINE__)
+    assert_equal(1, o.bug7942(), bug7942)
+    assert_equal(42, o.bug7942(a: 42), bug7942)
+  end
 end

Property changes on: ruby_2_0_0
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r39504


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

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