Caller(0)[1] returns :0 if not debugging


#1

Hi,

As promised, I’m trying to track down and reproduce various bugs I have
hit.

The first one I have is that my code is calling caller(0)[1] which
expects the path to the calling method. However, if i’m using running
the ir, then it can’t find the file or the method name, and the line
number is 0 in the stack trace, as such the information being returned
is incorrect which is causing expand_path to blow up. Hope that makes
sense?

E:\IronRuby\r156\build\debug>ir expandpath_call.rb
:0

E:\IronRuby\r156\build\debug>ir -D expandpath_call.rb
expandpath_call.rb:4

E:\IronRuby\r156\build\debug>ruby expandpath_call.rb
expandpath_call.rb:4

File: expandpath_call.rb
require ‘expandpath.rb’

$a = A.new
$a.method

File: expandpath.rb
class A
def method
puts caller(0)[1]
end
end

In the actual code, the stack frame looks something like this:
{#top-level-method#$18##18 at offset 10911 in file:line:column
:0:0}

Hope this helps

Cheers

Ben