[ruby-core:62446] [ruby-trunk - Bug #5330] [Rejected] Bug Report: wrong backtrace

From: akr@...
Date: 2014-05-07 13:12:33 UTC
List: ruby-core #62446
Issue #5330 has been updated by Akira Tanaka.

Status changed from Assigned to Rejected

Ulrich Kramer wrote:
>=20
> a.rb:
>   test =3D Class.new(Object)
>   test.class_eval(File.read("b.rb"),"b.rb",1)
>   test.run
>=20
> b.rb:
>   p caller
>   def self.run()
>     p caller
>   end
>=20
> When I run a.rb I got:
>   ["a.rb:2:in `class_eval'", "a.rb:2:in `<main>'"]
>   ["a.rb:3:in `<main>'"]
>=20
> Should be:
>   ["b.rb:1:in `class_eval'", "a.rb:2:in `<main>'"]
>   ["b.rb:3:in `<main>'"]

No.

caller() doesn't return the current stack frame unless 0 is specified as th=
e argument.

caller() returns an array which contains the caller stack frame and ancesto=
r 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 =3D 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=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20
["b.rb:1:in `<main>'", "a.rb:2:in `class_eval'", "a.rb:2:in `<main>'"]
["b.rb:3:in `run'", "a.rb:3:in `<main>'"]
```

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:=20
* Target version:=20
* ruby -v: ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]
* Backport:=20
----------------------------------------
=3Dbegin
I would like to report a ruby1.9 bug. I tried to create a new ticket in red=
mine. 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 =3D 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 `<main>'"]
  ["a.rb:3:in `<main>'"]

Should be:
  ["b.rb:1:in `class_eval'", "a.rb:2:in `<main>'"]
  ["b.rb:3:in `<main>'"]

ruby -v:
  ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]


Mit freundlichen Gr=C3=BC=C3=9Fen | best regards,

Ulrich Kramer
Senior Developer
=3Dend




--=20
https://bugs.ruby-lang.org/

In This Thread

Prev Next