Skip to content

Commit

Permalink
method.to_proc was providing 1-indexed line and not 0-indexed
Browse files Browse the repository at this point in the history
  • Loading branch information
enebo committed May 12, 2015
1 parent 04635bf commit 2774d78
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 3 additions & 1 deletion core/src/main/java/org/jruby/RubyMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ public IRubyObject to_proc(ThreadContext context) {
argsDesc = Helpers.methodToArgumentDescriptors(method);
}

body = new MethodBlockBody(runtime.getStaticScopeFactory().getDummyScope(), signature, method, argsDesc, receiver, originModule, originName, getFilename(), getLine());
int line = getLine(); // getLine adds 1 to 1-index but we need to reset to 0-index internally
body = new MethodBlockBody(runtime.getStaticScopeFactory().getDummyScope(), signature, method, argsDesc,
receiver, originModule, originName, getFilename(), line == -1 ? -1 : line - 1);
Block b = MethodBlockBody.createMethodBlock(body);

return RubyProc.newProc(runtime, b, Block.Type.LAMBDA);
Expand Down
1 change: 0 additions & 1 deletion spec/tags/ruby/core/proc/source_location_tags.txt

This file was deleted.

0 comments on commit 2774d78

Please sign in to comment.