Bug #632

StringIO has an odd alias implementation [?]

Added by Roger Pack over 3 years ago. Updated 10 months ago.

[ruby-core:19282]
Status:Closed Start date:10/11/2008
Priority:Normal Due date:12/24/2008
Assignee:Koichi Sasada % Done:

100%

Category:YARV
Target version:1.9.1 Release Candidate
ruby -v:

Description

Here's my situation:

require 'stringio'
class C < StringIO
 alias :old_init :initialize
 def initialize
   old_init
 end
end
C.new # fails 1.9, succeeds 1.8.6

normal classes:

class A
 def initialize
   print 'A init'
 end
end
class B < A
 alias :old_init :initialize
 def initialize
   old_init
 end
end
B.new # succeeds 1.9, 1.8

Thanks for your help! I know I'm annoying with this.

Related issues

related to ruby-trunk - Bug #730: Infinite recursion on 'super' in dynamically generated mo... Closed 11/09/2008 12/24/2008

Associated revisions

Revision 21084
Added by Koichi Sasada about 3 years ago

* vm_insnhelper.c (vm_call_method, vm_call_cfunc): use original id instead of calling id when NODE_CFUNC or NODE_BMETHOD. fixes Bug #632 [ruby-core:19282]. * vm_eval.c (vm_call0, vm_call_super): ditto. * vm_method.c (rb_add_method, rb_alias): store original id in nd_file field of NODE_METHOD. * test/stringio/test_stringio.rb: add a test.

Revision 21084
Added by Koichi Sasada about 3 years ago

* vm_insnhelper.c (vm_call_method, vm_call_cfunc): use original id instead of calling id when NODE_CFUNC or NODE_BMETHOD. fixes Bug #632 [ruby-core:19282]. * vm_eval.c (vm_call0, vm_call_super): ditto. * vm_method.c (rb_add_method, rb_alias): store original id in nd_file field of NODE_METHOD. * test/stringio/test_stringio.rb: add a test.

History

Updated by Koichi Sasada about 3 years ago

  • Assignee set to Yukihiro Matsumoto

Updated by Nobuyoshi Nakada about 3 years ago

  • Category set to core
  • Assignee changed from Yukihiro Matsumoto to Koichi Sasada
  • Target version set to 1.9.1 Release Candidate

Updated by Yuki Sonoda about 3 years ago

  • Due date set to 12/24/2008
  • Category changed from core to YARV

Updated by _ wanabe about 3 years ago

I guess the behavior is by this flow:
 +  C#initialize
 -> C#old_init ( == StringIO#initialize )
 -> strio_initialize()
 -> rb_call_super()
 -> Object#old_init
 -> NoMethodError

1.8 avoids the problem because ruby_frame->orig_func can differ from ruby_frame->last_func,
so Object#old_init is not called but Object#initialize is.

Updated by Koichi Sasada about 3 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100
Applied in changeset r21084.

Also available in: Atom PDF