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

nic*_*elo 8 ruby ruby-2.0

我正在关注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
Run Code Online (Sandbox Code Playgroud)

这被称为:

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
Run Code Online (Sandbox Code Playgroud)

问题是该行tv.channel = 10正在"破解"解释器并抛出:

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

我已经尝试使用Ruby 1.9.3的相同代码并且它正在工作.我正在使用Ruby 2.0.0-p195.

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

saw*_*awa 2

是的。这是ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-linux]. 在堆栈跟踪的末尾,它显示:

[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
Run Code Online (Sandbox Code Playgroud)

您应该将此报告给 Ruby 核心。为了 Ruby 社区,请这样做。

正如 matt 所指出的,它已在 Ruby 2.0.0p247 中修复。

我不认为你做错了什么。

  • 看起来这个问题在 p247 中已经修复了。 (3认同)