Issue #6038 has been reported by Denis de Bernardy.

----------------------------------------
Bug #6038: #instance_eval bug
https://bugs.ruby-lang.org/issues/6038

Author: Denis de Bernardy
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: 1.9.3


instance_eval seems to change the object_id in some cases:


begin
  stack = []
  do_stuff = lambda do |&chain|
    puts "Actual: #{chain.object_id}"
    chain.call
  end

  chain = lambda do
    if filter = stack.shift
      filter.call(&chain)
    end
  end

  puts "Expected: #{chain.object_id}"
  stack << do_stuff
  chain.instance_eval { @completed = false }
  chain.call
end

>> RUBY_VERSION
=> "1.9.3"
>> begin
?>   stack = []
>>   do_stuff = lambda do |&chain|
?>     puts "Actual: #{chain.object_id}"
>>     chain.call
>>   end
>> 
?>   chain = lambda do
?>     if filter = stack.shift
>>       filter.call(&chain)
>>     end
>>   end
>> 
?>   puts "Expected: #{chain.object_id}"
>>   stack << do_stuff
>>   chain.instance_eval { @completed = false }
>>   chain.call
>> end
Expected: 2152379740
Actual: 2152379520



-- 
http://bugs.ruby-lang.org/