Issue #17419 has been updated by mame (Yusuke Endoh).


Replacing `b.eval(src)` with `b.eval(src, *b.source_location)` will solve the issue.

However, #4352 focused on only `Kernel#eval`. I was not aware about the behavior change of `Binding#eval`. I've just added an explanation to NEWS.md at 4a18cc7f604c259415d933acd9fd00234733cab6.

----------------------------------------
Bug #17419: `binding.eval` backtrace differente
https://bugs.ruby-lang.org/issues/17419#change-89402

* Author: vo.x (Vit Ondruch)
* Status: Closed
* Priority: Normal
* ruby -v: ruby 3.0.0rc1 (2020-12-20 master 8680ae9cbd) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
Can somebody elaborate why there is different output for Ruby 2.7 vs Ruby 3.0?

~~~
$ ruby -v
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]

$ ruby -e '                                                                                                                                         
begin
binding.eval(%|raise "oops"|)
rescue Exception => exc
puts exc.backtrace
end
'
-e:3:in `<main>'
-e:3:in `eval'
-e:3:in `<main>'
~~~


~~~
$ ruby -v
ruby 3.0.0rc1 (2020-12-20 master 8680ae9cbd) [x86_64-linux]

$ ruby -e '                                                                                                                                         
begin
binding.eval(%|raise "oops"|)
rescue Exception => exc
puts exc.backtrace
end
'
(eval):1:in `<main>'
-e:3:in `eval'
-e:3:in `<main>'
~~~


IOW the first line of backtrace is different. Is this expected? This is causing test failures:

https://github.com/rails/web-console/issues/301



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

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>