加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-17 04:36:56 所属栏目:百科 来源:网络整理
导读:我正在关注 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 meth
我正在关注 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中得到了修复.

我没有看到你做错了什么.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读