Feature #16684

Use the word "to" instead of "from" in backtrace

Added by sawa (Tsuyoshi Sawada) 9 months ago. Updated 8 months ago.

Target version:


The most-recent-call-last order of backtrace introduced by #8661:

def a; raise end
def b; a end
def c; b end


Traceback (most recent call last):
    3: from foo.rb:4:in `<main>'
    2: from foo.rb:3:in `c'
    1: from foo.rb:2:in `b'
foo.rb:1:in `a': unhandled exception

is intuitive to me, and I hope it is retained. However, there are people complaining that it is confusing. I believe the unnaturalness is (at least partly) due to the fact that the word "from" is used, which made sense when backtrace was displayed in most-recent-call-first order,

foo.rb:1:in `a': unhandled exception
    1: from foo.rb:2:in `b'
    2: from foo.rb:3:in `c'
    3: from foo.rb:4:in `<main>'

but not any more. Here, my understanding is that "from" means that the previous line was called from that line.

I propose that, so long as the most-recent-call-last order is adopted, the word "to" should be used rather than "from", which would mean that the previous line leads to that line:

Proposed 1

Traceback (most recent call last):
    3: to foo.rb:4:in `<main>'
    2: to foo.rb:3:in `c'
    1: to foo.rb:2:in `b'
foo.rb:1:in `a': unhandled exception

Or, as an alternative, if it looks unnatural to have "to" in the first line, and to lack one before the message line, we may put it at the end of a line:

Proposed 2

Traceback (most recent call last)
    3: foo.rb:4:in `<main>' to:
    2: foo.rb:3:in `c' to:
    1: foo.rb:2:in `b' to:
foo.rb:1:in `a': unhandled exception

By using different words, it would become easier to understand the display order at a glance, and even by just looking at a single line.

Related issues

Related to CommonRuby - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)Closedmatz (Yukihiro Matsumoto)Actions

Also available in: Atom PDF