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

Proc source location gives wrong result #5286

Closed
enebo opened this Issue Aug 21, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@enebo
Copy link
Member

commented Aug 21, 2018

Originally reported by @jmalves in PR #5262

Environment

Ruby version: jruby 9.2.0.0 (2.5.0) 2018-05-24 81156a8 Java HotSpot(TM) 64-Bit Server VM 25.152-b16 on 1.8.0_152-b16 +jit [darwin-x86_64]
OS/platform: macOS 10.13.5

Expected Behavior

On ruby 2.5.0 and jruby-9.1.17.0 the following script:

expected = LINE + 1
proc = Proc.new do

end

p "#{expected} == #{proc.source_location[1]}"

Prints: 2 == 2
Actual Behavior

On jruby-9.2.0.0 it prints 2 == 5
Investigation

I found this bug by noticing that rspec with line filters (e.g. rspec test_file.rb:20) was not working.

I traced this back to ca25471

I am doubtful that the fix I proposed in this PR is adequate but anyway it was fun to look around this.

Tested with fast specs, mri's test_lambda and test_proc. No spec failures were added but also none were fixed :X

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.