Ruby 2.0抛出“[BUG]堆栈一致性错误”

时间:2013-07-07 14:35:48

标签: ruby ruby-2.0

我正在关注Ruby Koansabout_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。

那么,这是一个错误/错误吗?或者我正在做一些可怕的错误?

1 个答案:

答案 0 :(得分:2)

是。这是ruby 2.0.0p195 (2013-05-14 revision 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中修复。

我认为你没有做错任何事。