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?
NicoSantangelo
source share