gpt4 book ai didi

Ruby 2.0 抛出 "[BUG] Stack consistency error"

转载 作者:数据小太阳 更新时间:2023-10-29 06:54:59 24 4
gpt4 key购买 nike

我正在学习 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 中修复。

我没看到你做错了什么。

关于Ruby 2.0 抛出 "[BUG] Stack consistency error",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17513074/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com