ruby-changes:56825
From: nagachika <ko1@a...>
Date: Mon, 5 Aug 2019 23:06:27 +0900 (JST)
Subject: [ruby-changes:56825] nagachika: 6bb473ea37 (ruby_2_6): merge revision(s) 5e018214e7435030727a97ac49db038d96438e74: [Backport #15720]
https://git.ruby-lang.org/ruby.git/commit/?id=6bb473ea37 From 6bb473ea3778908aaa8da51bc8be63b86652e69a Mon Sep 17 00:00:00 2001 From: nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> Date: Mon, 5 Aug 2019 14:05:59 +0000 Subject: merge revision(s) 5e018214e7435030727a97ac49db038d96438e74: [Backport #15720] Fix SystemStackError when calling a method in an unused refinement Fixes [Bug #15720] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67729 b2dd03c8-39d4-4d8f-98ff-823fe69b080e diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb index 06150d9..38d0adb 100644 --- a/test/ruby/test_refinement.rb +++ b/test/ruby/test_refinement.rb @@ -2204,6 +2204,38 @@ class TestRefinement < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_refinement.rb#L2204 INPUT end + def test_call_method_in_unused_refinement + bug15720 = '[ruby-core:91916] [Bug #15720]' + assert_in_out_err([], <<-INPUT, ["ok"], [], bug15720) + module M1 + refine Kernel do + def foo + 'foo called!' + end + end + end + + module M2 + refine Kernel do + def bar + 'bar called!' + end + end + end + + using M1 + + foo + + begin + bar + rescue NameError + end + + puts "ok" + INPUT + end + def test_super_from_refined_module a = EnvUtil.labeled_module("A") do def foo;"[A#{super}]";end diff --git a/version.h b/version.h index 4015567..462aa01 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L1 #define RUBY_VERSION "2.6.3" #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR -#define RUBY_PATCHLEVEL 79 +#define RUBY_PATCHLEVEL 80 #define RUBY_RELEASE_YEAR 2019 #define RUBY_RELEASE_MONTH 8 diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 4f39a0f..4a47a8e 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -2315,7 +2315,10 @@ vm_call_method_each_type(rb_execution_context_t *ec, rb_control_frame_t *cfp, st https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L2315 goto no_refinement_dispatch; } } - cc->me = ref_me; + if (cc->me->def->type != VM_METHOD_TYPE_REFINED || + cc->me->def != ref_me->def) { + cc->me = ref_me; + } if (ref_me->def->type != VM_METHOD_TYPE_REFINED) { return vm_call_method(ec, cfp, calling, ci, cc); } -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/