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

ruby-changes:35056

From: nagachika <ko1@a...>
Date: Mon, 11 Aug 2014 22:22:37 +0900 (JST)
Subject: [ruby-changes:35056] nagachika:r47138 (ruby_2_1): merge revision(s) r46775: [Backport #10016]

nagachika	2014-08-11 22:22:31 +0900 (Mon, 11 Aug 2014)

  New Revision: 47138

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

  Log:
    merge revision(s) r46775: [Backport #10016]
    
    * vm_insnhelper.c (vm_callee_setup_keyword_arg): adjust VM stack
      pointer to get rid of overwriting splat arguments by arguments
      for `to_hash` conversion.  [ruby-core:63593] [Bug #10016]

  Modified directories:
    branches/ruby_2_1/
  Modified files:
    branches/ruby_2_1/ChangeLog
    branches/ruby_2_1/test/ruby/test_keyword.rb
    branches/ruby_2_1/version.h
    branches/ruby_2_1/vm_insnhelper.c
Index: ruby_2_1/ChangeLog
===================================================================
--- ruby_2_1/ChangeLog	(revision 47137)
+++ ruby_2_1/ChangeLog	(revision 47138)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1
+Mon Aug 11 22:14:28 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* vm_insnhelper.c (vm_callee_setup_keyword_arg): adjust VM stack
+	  pointer to get rid of overwriting splat arguments by arguments
+	  for `to_hash` conversion.  [ruby-core:63593] [Bug #10016]
+
 Fri Aug  8 23:36:01 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* ext/stringio/stringio.c (strio_write): use rb_str_append to
Index: ruby_2_1/version.h
===================================================================
--- ruby_2_1/version.h	(revision 47137)
+++ ruby_2_1/version.h	(revision 47138)
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1
 #define RUBY_VERSION "2.1.2"
-#define RUBY_RELEASE_DATE "2014-08-08"
-#define RUBY_PATCHLEVEL 196
+#define RUBY_RELEASE_DATE "2014-08-11"
+#define RUBY_PATCHLEVEL 197
 
 #define RUBY_RELEASE_YEAR 2014
 #define RUBY_RELEASE_MONTH 8
-#define RUBY_RELEASE_DAY 8
+#define RUBY_RELEASE_DAY 11
 
 #include "ruby/version.h"
 
Index: ruby_2_1/vm_insnhelper.c
===================================================================
--- ruby_2_1/vm_insnhelper.c	(revision 47137)
+++ ruby_2_1/vm_insnhelper.c	(revision 47138)
@@ -1067,10 +1067,15 @@ vm_caller_setup_args(const rb_thread_t * https://github.com/ruby/ruby/blob/trunk/ruby_2_1/vm_insnhelper.c#L1067
 }
 
 static inline int
-vm_callee_setup_keyword_arg(const rb_iseq_t *iseq, int argc, int m, VALUE *orig_argv, VALUE *kwd)
+vm_callee_setup_keyword_arg(rb_thread_t *th, const rb_iseq_t *iseq, int argc, int m, VALUE *orig_argv, VALUE *kwd)
 {
     VALUE keyword_hash = 0, orig_hash;
     int optional = iseq->arg_keywords - iseq->arg_keyword_required;
+    VALUE *const sp = th->cfp->sp;
+    const int mark_stack_len = th->mark_stack_len;
+
+    th->cfp->sp += argc;
+    th->mark_stack_len -= argc;
 
     if (argc > m &&
 	!NIL_P(orig_hash = rb_check_hash_type(orig_argv[argc-1])) &&
@@ -1085,10 +1090,14 @@ vm_callee_setup_keyword_arg(const rb_ise https://github.com/ruby/ruby/blob/trunk/ruby_2_1/vm_insnhelper.c#L1090
     rb_get_kwargs(keyword_hash, iseq->arg_keyword_table, iseq->arg_keyword_required,
 		  (iseq->arg_keyword_check ? optional : -1-optional),
 		  NULL);
+
     if (!keyword_hash) {
 	keyword_hash = rb_hash_new();
     }
 
+    th->cfp->sp = sp;
+    th->mark_stack_len = mark_stack_len;
+
     *kwd = keyword_hash;
 
     return argc;
@@ -1111,7 +1120,7 @@ vm_callee_setup_arg_complex(rb_thread_t https://github.com/ruby/ruby/blob/trunk/ruby_2_1/vm_insnhelper.c#L1120
 
     /* keyword argument */
     if (iseq->arg_keyword != -1) {
-	argc = vm_callee_setup_keyword_arg(iseq, argc, min, orig_argv, &keyword_hash);
+	argc = vm_callee_setup_keyword_arg(th, iseq, argc, min, orig_argv, &keyword_hash);
     }
 
     /* mandatory */
@@ -2212,7 +2221,7 @@ vm_yield_setup_block_args(rb_thread_t *t https://github.com/ruby/ruby/blob/trunk/ruby_2_1/vm_insnhelper.c#L2221
 
     /* keyword argument */
     if (iseq->arg_keyword != -1) {
-	argc = vm_callee_setup_keyword_arg(iseq, argc, min, argv, &keyword_hash);
+	argc = vm_callee_setup_keyword_arg(th, iseq, argc, min, argv, &keyword_hash);
     }
 
     for (i=argc; i<m; i++) {
Index: ruby_2_1/test/ruby/test_keyword.rb
===================================================================
--- ruby_2_1/test/ruby/test_keyword.rb	(revision 47137)
+++ ruby_2_1/test/ruby/test_keyword.rb	(revision 47138)
@@ -463,6 +463,16 @@ class TestKeywordArguments < Test::Unit: https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/test_keyword.rb#L463
     assert_equal({a: 1, b: 2}, m1(**o, **o2) {|x| break x}, bug9898)
   end
 
+  def test_implicit_hash_conversion
+    bug10016 = '[ruby-core:63593] [Bug #10016]'
+
+    o = Object.new
+    def o.to_hash() { k: 9 } end
+    assert_equal([1, 42, [], o, :key, {}, nil], f9(1, o))
+    assert_equal([1, 9], m1(1, o) {|a, k: 0| break [a, k]}, bug10016)
+    assert_equal([1, 9], m1(1, o, &->(a, k: 0) {break [a, k]}), bug10016)
+  end
+
   def test_gced_object_in_stack
     bug8964 = '[ruby-dev:47729] [Bug #8964]'
     assert_normal_exit %q{

Property changes on: ruby_2_1
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r46775


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

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