Find some error with exception

run following script

def foo(i)
foo(i+1)
end
def main1
begin
foo(1)
rescue
puts $!.backtrace.join("\n")
end
end

def main2
begin
foo(1)
rescue
puts $!.backtrace.join("\n")
end
end

main1
main2

this will has to “stack too deep” error at DIFFERENT line of the script
but the result will be

mm.rb:2:in foo' mm.rb:2:infoo’
mm.rb:8:in main1' mm.rb:22 mm.rb:2:infoo’
mm.rb:2:in foo' mm.rb:8:inmain1’
mm.rb:22

both show the 1st error position
this error should be correct

What are you trying to accomplish? Infinite recursion is generally not
a really good idea unless you want to cripple your machine
temporarily.
-tim

“T” == Tim B. [email protected] writes:

T> What are you trying to accomplish?

Read carefully his message.

main1
^^^^^
main2
^^^^^

mm.rb:8:in main1' ^^^^^ mm.rb:8:in main1’
^^^^^

In NODE_RESCUE, ruby_errinfo is reset to Qnil (well to e_info) but the
backtrace is not reset, this is why ruby not rebuild it.

Guy Decoux