ruby-changes:44447
From: nobu <ko1@a...>
Date: Sat, 29 Oct 2016 09:39:25 +0900 (JST)
Subject: [ruby-changes:44447] nobu:r56520 (trunk): vm_eval.c: follow the original class
nobu 2016-10-29 09:39:16 +0900 (Sat, 29 Oct 2016) New Revision: 56520 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56520 Log: vm_eval.c: follow the original class * vm_eval.c (vm_call0_body): follow the original class, not to loop the prepended module. [ruby-core:77784] [Bug #12876] Modified files: trunk/ChangeLog trunk/test/ruby/test_super.rb trunk/vm_eval.c Index: ChangeLog =================================================================== --- ChangeLog (revision 56519) +++ ChangeLog (revision 56520) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Oct 29 09:39:14 2016 Nobuyoshi Nakada <nobu@r...> + + * vm_eval.c (vm_call0_body): follow the original class, not to + loop the prepended module. [ruby-core:77784] [Bug #12876] + Sat Oct 29 00:14:30 2016 Nobuyoshi Nakada <nobu@r...> * enc/trans/windows-1255-tbl.rb: update mapping from 0xCA to Index: test/ruby/test_super.rb =================================================================== --- test/ruby/test_super.rb (revision 56519) +++ test/ruby/test_super.rb (revision 56520) @@ -530,4 +530,18 @@ class TestSuper < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_super.rb#L530 assert_equal "b", b.new.foo{"c"} end + + def test_public_zsuper_with_prepend + bug12876 = '[ruby-core:77784] [Bug #12876]' + m = EnvUtil.labeled_module("M") + c = EnvUtil.labeled_class("C") {prepend m; public :initialize} + o = assert_nothing_raised(Timeout::Error, bug12876) { + Timeout.timeout(3) {c.new} + } + assert_instance_of(c, o) + m.module_eval {def initialize; raise "exception in M"; end} + assert_raise_with_message(RuntimeError, "exception in M") { + c.new + } + end end Index: vm_eval.c =================================================================== --- vm_eval.c (revision 56519) +++ vm_eval.c (revision 56520) @@ -201,7 +201,7 @@ vm_call0_body(rb_thread_t* th, struct rb https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L201 goto again; } - super_class = RCLASS_SUPER(cc->me->defined_class); + super_class = RCLASS_SUPER(RCLASS_ORIGIN(cc->me->defined_class)); if (!super_class || !(cc->me = rb_callable_method_entry(super_class, ci->mid))) { enum method_missing_reason ex = (type == VM_METHOD_TYPE_ZSUPER) ? MISSING_SUPER : 0; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/