From: akr@... Date: 2014-05-07T13:12:33+00:00 Subject: [ruby-core:62446] [ruby-trunk - Bug #5330] [Rejected] Bug Report: wrong backtrace Issue #5330 has been updated by Akira Tanaka. Status changed from Assigned to Rejected Ulrich Kramer wrote: > > a.rb: > test = Class.new(Object) > test.class_eval(File.read("b.rb"),"b.rb",1) > test.run > > b.rb: > p caller > def self.run() > p caller > end > > When I run a.rb I got: > ["a.rb:2:in `class_eval'", "a.rb:2:in `
'"] > ["a.rb:3:in `
'"] > > Should be: > ["b.rb:1:in `class_eval'", "a.rb:2:in `
'"] > ["b.rb:3:in `
'"] No. caller() doesn't return the current stack frame unless 0 is specified as the argument. caller() returns an array which contains the caller stack frame and ancestor stack frames. caller of the top level of b.rb is test.class_eval described in a.rb. caller of "run" method is the top level of a.rb. caller(0) makes things clear. ``` % cat a.rb test = Class.new(Object) test.class_eval(File.read("b.rb"),"b.rb",1) test.run % cat b.rb p caller(0) def self.run() p caller(0) end % ./ruby a.rb ["b.rb:1:in `
'", "a.rb:2:in `class_eval'", "a.rb:2:in `
'"] ["b.rb:3:in `run'", "a.rb:3:in `
'"] ``` b.rb:1 and b.rb:3 appears as the first element (current stack frame). The second element shows the stack frame in a.rb. ---------------------------------------- Bug #5330: Bug Report: wrong backtrace https://bugs.ruby-lang.org/issues/5330#change-46594 * Author: Ulrich Kramer * Status: Rejected * Priority: Normal * Assignee: Akira Tanaka * Category: * Target version: * ruby -v: ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux] * Backport: ---------------------------------------- =begin I would like to report a ruby1.9 bug. I tried to create a new ticket in redmine. After registration(wonderix) I tried to login, but I didn't succeed. After 4 password resets I gave up. So here is my description: a.rb: test = Class.new(Object) test.class_eval(File.read("b.rb"),"b.rb",1) test.run b.rb: p caller def self.run() p caller end When I run a.rb I got: ["a.rb:2:in `class_eval'", "a.rb:2:in `
'"] ["a.rb:3:in `
'"] Should be: ["b.rb:1:in `class_eval'", "a.rb:2:in `
'"] ["b.rb:3:in `
'"] ruby -v: ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux] Mit freundlichen Gr����en | best regards, Ulrich Kramer Senior Developer =end -- https://bugs.ruby-lang.org/