Skip to content

Proc source location gives wrong result #5286

@enebo

Description

@enebo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions