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

ruby-changes:33956

From: nobu <ko1@a...>
Date: Wed, 21 May 2014 15:11:32 +0900 (JST)
Subject: [ruby-changes:33956] nobu:r46037 (trunk): vm.c: rewind cfp

nobu	2014-05-21 15:11:25 +0900 (Wed, 21 May 2014)

  New Revision: 46037

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

  Log:
    vm.c: rewind cfp
    
    * vm.c (m_core_hash_{from_ary,merge_{ary,ptr,kwd}}): rewind cfp to
      show proper backtrace.  [ruby-dev:35820] [Bug #416]

  Modified files:
    trunk/test/ruby/test_backtrace.rb
    trunk/vm.c
Index: vm.c
===================================================================
--- vm.c	(revision 46036)
+++ vm.c	(revision 46037)
@@ -2259,7 +2259,9 @@ m_core_set_postexe(VALUE self) https://github.com/ruby/ruby/blob/trunk/vm.c#L2259
     return Qnil;
 }
 
-static VALUE m_core_hash_merge_ary(VALUE self, VALUE hash, VALUE ary);
+static VALUE core_hash_merge_ary(VALUE hash, VALUE ary);
+static VALUE core_hash_from_ary(VALUE ary);
+static VALUE core_hash_merge_kwd(int argc, VALUE *argv);
 
 static VALUE
 core_hash_merge(VALUE hash, long argc, const VALUE *argv)
@@ -2276,18 +2278,33 @@ core_hash_merge(VALUE hash, long argc, c https://github.com/ruby/ruby/blob/trunk/vm.c#L2278
 static VALUE
 m_core_hash_from_ary(VALUE self, VALUE ary)
 {
+    VALUE hash;
+    REWIND_CFP(hash = core_hash_from_ary(ary));
+    return hash;
+}
+
+static VALUE
+core_hash_from_ary(VALUE ary)
+{
     VALUE hash = rb_hash_new();
 
     if (RUBY_DTRACE_HASH_CREATE_ENABLED()) {
 	RUBY_DTRACE_HASH_CREATE(RARRAY_LEN(ary), rb_sourcefile(), rb_sourceline());
     }
 
-    return m_core_hash_merge_ary(self, hash, ary);
+    return core_hash_merge_ary(hash, ary);
 }
 
 static VALUE
 m_core_hash_merge_ary(VALUE self, VALUE hash, VALUE ary)
 {
+    REWIND_CFP(core_hash_merge_ary(hash, ary));
+    return hash;
+}
+
+static VALUE
+core_hash_merge_ary(VALUE hash, VALUE ary)
+{
     core_hash_merge(hash, RARRAY_LEN(ary), RARRAY_CONST_PTR(ary));
     return hash;
 }
@@ -2297,7 +2314,7 @@ m_core_hash_merge_ptr(int argc, VALUE *a https://github.com/ruby/ruby/blob/trunk/vm.c#L2314
 {
     VALUE hash = argv[0];
 
-    core_hash_merge(hash, argc-1, argv+1);
+    REWIND_CFP(core_hash_merge(hash, argc-1, argv+1));
 
     return hash;
 }
@@ -2330,6 +2347,14 @@ kwcheck_i(VALUE key, VALUE value, VALUE https://github.com/ruby/ruby/blob/trunk/vm.c#L2347
 static VALUE
 m_core_hash_merge_kwd(int argc, VALUE *argv, VALUE recv)
 {
+    VALUE hash;
+    REWIND_CFP(hash = core_hash_merge_kwd(argc, argv));
+    return hash;
+}
+
+static VALUE
+core_hash_merge_kwd(int argc, VALUE *argv)
+{
     VALUE hash, kw;
     rb_check_arity(argc, 1, 2);
     hash = argv[0];
Index: test/ruby/test_backtrace.rb
===================================================================
--- test/ruby/test_backtrace.rb	(revision 46036)
+++ test/ruby/test_backtrace.rb	(revision 46037)
@@ -234,4 +234,11 @@ class TestBacktrace < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/ruby/test_backtrace.rb#L234
     end
     assert_not_match(/\Acore#/, e.backtrace_locations[0].base_label)
   end
+
+  def test_core_backtrace_hash_merge
+    e = assert_raise(TypeError) do
+      {**nil}
+    end
+    assert_not_match(/\Acore#/, e.backtrace_locations[0].base_label)
+  end
 end

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

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