Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line numbers in backtrace with multiline method invocation are sometimes different from CRuby (again) #4737

Closed
yujinakayama opened this Issue Aug 10, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@yujinakayama
Copy link

yujinakayama commented Aug 10, 2017

This is similar to #4664.

As @enebo said in #4664 (comment):

I corrected this for fcall nodes but I imagine other cases exist. This at least fixes the reported issue...

... it seems this is another case.


When there's a method invocation with multiline method invocation as an argument:

puts "RUBY_ENGINE: #{RUBY_ENGINE}"
puts "RUBY_VERSION: #{RUBY_VERSION}"
puts "JRUBY_VERSION: #{JRUBY_VERSION}" if defined?(JRUBY_VERSION)
puts '=' * 40

def expect(*)
  Expectation.new
end

class Expectation
  def to(matcher)
    raise
  end
end

class Matcher
  def and(matcher)
  end
end

begin
  expect('something').to Matcher.new # Line 22
                    .and Matcher.new # Line 23
rescue => error
  puts error.backtrace
end

... JRuby reports the following backtrace:

RUBY_ENGINE: jruby
RUBY_VERSION: 2.3.3
JRUBY_VERSION: 9.1.12.0
========================================
test.rb:12:in `to'
test.rb:23:in `<main>'

... in contrast to CRuby:

RUBY_ENGINE: ruby
RUBY_VERSION: 2.4.1
========================================
test.rb:12:in `to'
test.rb:22:in `<main>'

Environment

$ jruby -v
jruby 9.1.12.0 (2.3.3) 2017-06-15 33c6439 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.7.0 Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64 x86_64

Expected Behavior

With the above script, backtrace should include the beginning line number of the method invocation (the expect('something').to Matcher.new line) as CRuby does.

Actual Behavior

JRuby 9.1.10.0 reports backtrace including the last line number of the method invocation (the .and Matcher.new) line).

yujinakayama added a commit to rspec/rspec-core that referenced this issue Aug 10, 2017

Mark failing examples on JRuby 9000 as pending
They are failing due to a bug in JRuby 9000.

jruby/jruby#4737

@enebo enebo added this to the JRuby 9.1.13.0 milestone Aug 16, 2017

@enebo enebo closed this in d73a05b Aug 17, 2017

@enebo

This comment has been minimized.

Copy link
Member

enebo commented Aug 17, 2017

@yujinakayama I have no doubt this is the last one you will find but we will keep chipping away. Keep these reports coming :)

enebo added a commit that referenced this issue Aug 17, 2017

Fixes #4737. Line numbers in backtrace with multiline method invocati…
…on are sometimes different from CRuby (again)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.