Project

General

Profile

Backport #2728 ยป ensure_dynamic_method.rb

Script which will reproduce the crash. - Ethan (Ethan -), 02/10/2010 01:26 AM

 
1
class Object
2
  define_method 'dynamically_defined_method' do
3
    puts "hello from a dynamically defined method!"
4
  end
5
end
6

    
7
module SomeEnumerator
8
  # pretend to be an enumerable over one thing (:foo)
9
  def self.each
10
    begin
11
      # yield to the block passed from whatever Enumerable method
12
      yield :foo
13
    ensure
14
      dynamically_defined_method
15
      puts "done with the dynamically defined method"
16
    end
17
  end
18
  extend Enumerable
19

    
20
end
21

    
22
# these all segfault 
23
SomeEnumerator.detect{true} # => :foo
24
SomeEnumerator.any?{true} # => true
25
SomeEnumerator.all?{false} # => false
26
SomeEnumerator.include?(:foo) # => true