-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Labels
Milestone
Description
When there's a method invocation with multiline method invocation as an argument:
def do_something(*)
raise
end
begin
do_something(Object # Line 6
.new) # Line 7
rescue => error
puts error.backtrace
end... JRuby reports the following backtrace:
test.rb:2:in `do_something'
test.rb:7:in `<main>'
... in contrast to CRuby:
test.rb:2:in `do_something'
test.rb:6:in `<main>'
Environment
$ jruby -v
jruby 9.1.10.0 (2.3.3) 2017-05-25 b09c48a Java HotSpot(TM) 64-Bit Server VM 25.25-b02 on 1.8.0_25-b17 +jit [darwin-x86_64]
$ uname -a
Darwin macbookpro.local 16.6.0 Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64 x86_64
Expected Behavior
With the following script:
def do_something(*)
raise
end
def print_error_line(error)
line_number = error.backtrace[1].split(':')[1].to_i
p File.read(__FILE__).lines[line_number - 1]
end
puts "RUBY_ENGINE: #{RUBY_ENGINE}"
puts "RUBY_VERSION: #{RUBY_VERSION}"
puts "JRUBY_VERSION: #{JRUBY_VERSION}" if defined?(JRUBY_VERSION)
begin
do_something(Object
.new)
rescue => error
puts '=' * 40
puts error.backtrace
print_error_line(error)
endBacktrace should include the beginning line number of the method invocation (the do_something line), as CRuby does:
$ ruby test.rb
RUBY_ENGINE: ruby
RUBY_VERSION: 2.4.1
========================================
test.rb:2:in `do_something'
test.rb:15:in `<main>'
" do_something(Object\n"
Actual Behavior
JRuby 9.1.10.0 reports backtrace including the last line number of the method invocation (the .new) line):
$ ruby test.rb
RUBY_ENGINE: jruby
RUBY_VERSION: 2.3.3
JRUBY_VERSION: 9.1.10.0
========================================
test.rb:2:in `do_something'
test.rb:16:in `<main>'
" .new)\n"
Reactions are currently unavailable