Project

General

Profile

Backport #2728 » ensure_dynamic_method.rb

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

 
class Object
define_method 'dynamically_defined_method' do
puts "hello from a dynamically defined method!"
end
end

module SomeEnumerator
# pretend to be an enumerable over one thing (:foo)
def self.each
begin
# yield to the block passed from whatever Enumerable method
yield :foo
ensure
dynamically_defined_method
puts "done with the dynamically defined method"
end
end
extend Enumerable

end

# these all segfault
SomeEnumerator.detect{true} # => :foo
SomeEnumerator.any?{true} # => true
SomeEnumerator.all?{false} # => false
SomeEnumerator.include?(:foo) # => true
(1-1/3)