1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

insns.def: method entry from method frame

* insns.def (defined): get method entry from the method top level
  frame, not block frame.  [ruby-core:54769] [Bug #8367]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-05-05 07:29:44 +00:00
parent 13bd7afc6e
commit 08fbd2cee2
3 changed files with 32 additions and 0 deletions

View file

@ -1,3 +1,8 @@
Sun May 5 16:29:41 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* insns.def (defined): get method entry from the method top level
frame, not block frame. [ruby-core:54769] [Bug #8367]
Sun May 5 13:28:54 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* template/ruby.pc.in (Cflags): use rubyarchhdrdir for multiarch.

View file

@ -765,6 +765,17 @@ defined
break;
case DEFINED_ZSUPER:{
const rb_method_entry_t *me = GET_CFP()->me;
if (!me) {
const rb_control_frame_t *end_cfp = RUBY_VM_END_CONTROL_FRAME(GET_THREAD());
const rb_control_frame_t *cfp = GET_CFP();
const VALUE *const local_ep = rb_vm_ep_local_ep(cfp->ep);
while (RUBY_VM_VALID_CONTROL_FRAME_P(cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp), end_cfp)) {
if (cfp->ep == local_ep) {
me = cfp->me;
break;
}
}
}
if (me) {
VALUE klass = vm_search_normal_superclass(GET_CFP()->klass);
ID id = me->def ? me->def->original_id : me->called_id;

View file

@ -188,4 +188,20 @@ class TestDefined < Test::Unit::TestCase
end
assert_equal("super", c.new.m)
end
def test_super_in_block
bug8367 = '[ruby-core:54769] [Bug #8367]'
c = Class.new do
def x; end
end
m = Module.new do
def b; yield; end
def x; b {return defined?(super)}; end
end
o = c.new
o.extend(m)
assert_equal("super", o.x)
end
end