LoginSignup
1
1

More than 5 years have passed since last update.

#ruby 2.0 crashed

Last updated at Posted at 2014-01-08
lazy_select.rb
class Enumerator
  class Lazy
    alias :select_without_block :select
    def select(&block)
      return to_enum(:select) if !block_given?
      select_without_block(&block)
    end
  end
end
p (1..999999999).lazy.select.with_index{|e,i|i.odd?}.take(10).to_a

ruby1.9 -v
ruby 1.9.3p194 (2012-04-20) [i686-linux]
ruby1.9 -rbackports lazy_select.rb
[2, 4, 6, 8, 10, 12, 14, 16, 18, 20]

ruby2.0 lazy_select.rb
[BUG] vm_call_cfunc - cfp consistency error
ruby 2.0.0p247 (2013-06-27 revision 41674) [universal.x86_64-darwin13]

いやですね、本当は http://antimon2.hatenablog.jp/entry/2014/01/08/235706 への肯定的な解答にしたかったんですよ( https://github.com/yhara/enumerable-lazy/blob/master/lib/enumerable/lazy.rb でもantimon2/enumerable_lzに謝辞書かれてますし )。
しかしまさかのクラッシュ…。

PS
Lazy.class_eval{}とすれば、ruby1.9 -renumerable/lazyでも期待通りの動作をします。

PPS
antimon2氏がRuby 2.1.0でテストしたところ、期待通りの動作だったそうです。ありがとうございました。
問題はOSXのRubyがいつ更新されるかなんだよなぁ…。

1
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1