Ruby 2.0 throws "[BUG] Stack Consistency Error"

I follow the Ruby Koans exercises and in about_proxy_object_project.rb there is this bit of code:

 class Proxy def initialize(target_object) @object = target_object end # This method was added by me def method_missing(method_name, *args, &block) @object.send method_name end end 

It is called like this:

 def test_tv_methods_still_perform_their_function tv = Proxy.new(Television.new) # Television is a class with a :channel attr_accessor and a power method tv.channel = 10 tv.power assert_equal 10, tv.channel assert tv.on? end 

The problem is that the line tv.channel = 10 is a "violation" of the interpreter and throwing:

 [BUG] Stack consistency error (sp: 53, bp: 54) ruby 2.0.0p0 (...) full stack trace follows 

I tried the same code with Ruby 1.9.3 and it works. I am using Ruby 2.0.0-p195.

So is this a bug / bug? Or am I doing something terribly wrong?

+8
source share
1 answer

Yes. This is a Ruby bug in ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-linux] . At the end of the stack trace, it says:

 [NOTE] You may have encountered a bug in the Ruby interpreter or extension libraries. Bug reports are welcome. For details: http://www.ruby-lang.org/bugreport.html 

You must report this to the Ruby core. Please do this for the sake of the Ruby community.

As indicated by the mat, it is fixed in Ruby 2.0.0p247.

I don’t see you doing something wrong.

+2
source share

All Articles