我下面從Ruby Koans和about_proxy_object_project.rb
練習有這段代碼:紅寶石2.0拋出「[BUG]棧一致性錯誤」
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。
那麼,這是一個錯誤/錯誤?或者我正在做一些可怕的錯誤?
馬特指出,它似乎已在6月27日發佈的p247中得到修復。 – sawa