Forum: Ruby-core [ruby-trunk - Bug #8055][Open] Method with the same name as accessor causes stack level too deep err

Be506f086d64d0d8815adaadb1d6c639?d=identicon&s=25 firedev (Nick O) (Guest)
on 2013-03-09 09:30
(Received via mailing list)
Issue #8055 has been reported by firedev (Nick O).

----------------------------------------
Bug #8055: Method with the same name as accessor causes stack level too
deep error
https://bugs.ruby-lang.org/issues/8055

Author: firedev (Nick O)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: 1.9.3


To me this looks like a bug. It causes stack level too deep in all
versions of Ruby (1.9 and 2.0 at least).

  class Test
    attr_accessor :uuid
    def uuid
        self.uuid ||=1
    end
  end

  > Test.new.uuid
  SystemStackError: stack level too deep
  from
/Users/pain/.rbenv/versions/1.9.3-p374/lib/ruby/1.9.1/irb/workspace.rb:80
  Maybe IRB bug!
F52e87b92cafb1e8c6d155076b56ecff?d=identicon&s=25 "duerst (Martin Dürst)" <duerst@it.aoyama.ac.jp> (Guest)
on 2013-03-09 09:38
(Received via mailing list)
Issue #8055 has been updated by duerst (Martin Dürst).

Status changed from Open to Rejected

An accessor is just a method. If you then use def to define a method
with the same name, the accessor gets overwritten. You end up with a
recursive method, which will blow up the stack. You can do that even
quicker:

def a
  a
end

> a
SystemStackError: stack level too deep
----------------------------------------
Bug #8055: Method with the same name as accessor causes stack level too
deep error
https://bugs.ruby-lang.org/issues/8055#change-37419

Author: firedev (Nick O)
Status: Rejected
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: 1.9.3


To me this looks like a bug. It causes stack level too deep in all
versions of Ruby (1.9 and 2.0 at least).

  class Test
    attr_accessor :uuid
    def uuid
        self.uuid ||=1
    end
  end

  > Test.new.uuid
  SystemStackError: stack level too deep
  from
/Users/pain/.rbenv/versions/1.9.3-p374/lib/ruby/1.9.1/irb/workspace.rb:80
  Maybe IRB bug!
This topic is locked and can not be replied to.