Project

General

Profile

Actions

Backport #146

closed

Incorrect line numbers in "caller" output when evaluated in a Proc binding

Added by wilson (Wilson Bilkovich) almost 16 years ago. Updated over 4 years ago.


Description

=begin
The second frame's line number appears to always be incorrect when a Proc is created via a non-toplevel method call.
This small program and its output illustrate the issue:

def first # line 1 of proc_caller.rb on my system
second
end

def second
b = third do
1 + 1
end
return b
end

def third(&b)
return b
end

eval("p caller(0)", first)

Output on recent 1.8 releases, including 1.8.6 and 1.8.7:
["proc_caller.rb:6:in second'", "proc_caller.rb:6:in first'", "proc_caller.rb:16"]

Output that I would expect: (line 6 is in 'second', not 'first')
["proc_caller.rb:6:in second'", "proc_caller.rb:2:in first'", "proc_caller.rb:16"]
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0