Project

General

Profile

Actions

Bug #17466

closed

Inconsistent backtrace order in Ruby 3.0

Added by jnchito (Junichi Ito) almost 4 years ago. Updated almost 4 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 3.0.0dev (2020-12-19T22:13:08Z master 6343a81129) [x86_64-darwin20]
[ruby-core:101665]

Description

I found the backtrace order is different between ruby sample.rb and irb in Ruby 3.0.

# sample.rb
puts RUBY_DESCRIPTION
class A
  def hoge
    fuga
  end

  def fuga
    1/0
  end
end
A.new.hoge
$ ruby sample.rb
ruby 3.0.0dev (2020-12-19T22:13:08Z master 6343a81129) [x86_64-darwin20]
sample.rb:8:in `/': divided by 0 (ZeroDivisionError)
	from sample.rb:8:in `fuga'
	from sample.rb:4:in `hoge'
	from sample.rb:11:in `<main>'
$ irb --prompt simple
>> puts RUBY_DESCRIPTION
ruby 3.0.0dev (2020-12-19T22:13:08Z master 6343a81129) [x86_64-darwin20]
=> nil
?> class A
?>   def hoge
?>     fuga
?>   end
?> 
?>   def fuga
?>     1/0
?>   end
>> end
=> :fuga
>> A.new.hoge
Traceback (most recent call last):
        7: from /Users/jnito/.rbenv/versions/3.0.0-dev/bin/irb:23:in `<main>'
        6: from /Users/jnito/.rbenv/versions/3.0.0-dev/bin/irb:23:in `load'
        5: from /Users/jnito/.rbenv/versions/3.0.0-dev/lib/ruby/gems/3.0.0/gems/irb-1.2.7/exe/irb:11:in `<top (required)>'
        4: from (irb):11:in `<main>'
        3: from (irb):4:in `hoge'
        2: from (irb):8:in `fuga'
        1: from (irb):8:in `/'
ZeroDivisionError (divided by 0)

I'd like to have the same order because such an inconsistent results would confuse developers (especially beginners).

This issue is related to https://bugs.ruby-lang.org/issues/8661


Files

Screen Shot 2020-12-24 at 8.38.53.png (992 KB) Screen Shot 2020-12-24 at 8.38.53.png jnchito (Junichi Ito), 12/23/2020 11:41 PM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0