我正在关注
Ruby Koans和about_proxy_object_project.rb中的练习,这里有一些代码:
- 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
这被称为:
- 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
问题是,tv.channel = 10行正在“破解”解释器并抛出:
- [BUG] Stack consistency error (sp: 53,bp: 54)
- ruby 2.0.0p0
- (...)
- full stack trace follows
我在Ruby 1.9.3上尝试了相同的代码并且它正在运行.我正在使用Ruby 2.0.0-p195.
解决方法
是.这是ruby 2.0.0p195(2013-05-14修订版40734)[x86_64-linux]中的Ruby错误.在堆栈跟踪结束时,它说:
- [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
您应该将此报告给Ruby核心.请为Ruby社区这样做.
正如matt指出的那样,它在Ruby 2.0.0p247中得到了修复.
我没有看到你做错了什么.