I am trying to understand what Ruby 1.8 outputs when "caller" is invoked.
I am working on making Rubinius produce compatible results, but there
are some scenarios I have not been able to understand.  The one
outlined below looks like a Ruby bug to me.

Can someone confirm or deny that for me?

Here is a test script that shows a medium-complexity call to 'caller':

# cat caller_output.rb
def caller_in_eval
  eval "caller(0)"
end

def method_with_block
  yield
end

method_with_block do
  p caller_in_eval
end

In Ruby 1.8.6, this outputs:
["(eval):1:in `caller_in_eval'",
"caller_output.rb:10:in `eval'",
"caller_output.rb:2:in `caller_in_eval'",
"caller_output.rb:10",
"caller_output.rb:6:in `method_with_block'",
"caller_output.rb:9"]

Going frame by frame:
1)  (eval):1 is fine.. caller(0) shows the current stack frame as well
as the previous, and the current stack frame inside the call to 'eval'
is of course line 1 of the eval 'method body'.

2)  caller_output.rb:10:in eval -- Whoa what is going on here? What
happened to line 2 inside caller_in_eval, the method that invoked
"eval". That is definitely what I expected to see as the second frame.
 Instead, we jump over it to line 10, where "caller_in_eval" was
called.

3) Why are we back on line 2 again? Line 2 surely did not invoke line
10 of this script, but that is what the caller output is claiming.

4) Line 10 again? Seeing frames on line 10 on either side of the line
2 frame makes no sense to me. This doesn't seem to represent the real
execution order at all so far.

5) caller_output.rb:6 -- This seems correct to me.. line 6 is what
yielded to the block, which, on line 10, calls the 'caller_in_eval'
method.

6) caller_output.rb:9 -- Also looks fine.   Line 9 was where the
method with the attached block was called from.


Here is the output I would expect to see from this code:
["(eval):1:in `caller_in_eval'",
"caller_output.rb:2:in `caller_in_eval'",
"caller_output.rb:10",
"caller_output.rb:6:in `method_with_block'",
"caller_output.rb:9"]

Thanks for any help you can provide,
--Wilson.