mirror of
https://github.com/ruby/ruby.git
synced 2025-09-16 00:54:01 +02:00
Fix SystemStackError when calling a method in an unused refinement
Fixes [Bug #15720]
This commit is contained in:
parent
4f9e7c95e4
commit
5e018214e7
2 changed files with 36 additions and 1 deletions
|
@ -2242,6 +2242,38 @@ class TestRefinement < Test::Unit::TestCase
|
||||||
INPUT
|
INPUT
|
||||||
end
|
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
|
def test_super_from_refined_module
|
||||||
a = EnvUtil.labeled_module("A") do
|
a = EnvUtil.labeled_module("A") do
|
||||||
def foo;"[A#{super}]";end
|
def foo;"[A#{super}]";end
|
||||||
|
|
|
@ -2635,7 +2635,10 @@ vm_call_method_each_type(rb_execution_context_t *ec, rb_control_frame_t *cfp, st
|
||||||
goto no_refinement_dispatch;
|
goto no_refinement_dispatch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (cc->me->def->type != VM_METHOD_TYPE_REFINED ||
|
||||||
|
cc->me->def != ref_me->def) {
|
||||||
cc->me = ref_me;
|
cc->me = ref_me;
|
||||||
|
}
|
||||||
if (ref_me->def->type != VM_METHOD_TYPE_REFINED) {
|
if (ref_me->def->type != VM_METHOD_TYPE_REFINED) {
|
||||||
return vm_call_method(ec, cfp, calling, ci, cc);
|
return vm_call_method(ec, cfp, calling, ci, cc);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue