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

Ben Hall ben2004uk at googlemail.com
Mon Oct 6 17:22:18 EDT 2008


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

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

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

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

File: expandpath_call.rb
require 'expandpath.rb'

$a = A.new

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

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

Hope this helps


-------------- next part --------------
A non-text attachment was scrubbed...
Name: expandpath.rb
Type: application/octet-stream
Size: 108 bytes
Desc: not available
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20081006/c805df34/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: expandpath_call.rb
Type: application/octet-stream
Size: 48 bytes
Desc: not available
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20081006/c805df34/attachment-0001.obj>

More information about the Ironruby-core mailing list