Project

General

Profile

Actions

Bug #5930

closed

source_location of blocks incorrect

Added by charlton (Charlton Wang) over 12 years ago. Updated about 12 years ago.

Status:
Closed
Target version:
-
ruby -v:
1.9.2-p136 and newer
Backport:
[ruby-core:42232]

Description

Similar to bug [ruby-core:27014]) (Closed)" href="/issues/2427">#2427 but maybe the opposite problem. Newer versions of ruby appear to store the source locations of blocks incorrectly when passed as an argument to a multi-line invocation of a function. Snippet of code below reveals the problem:


def foo(*args, &block)
p block.source_location
end

foo(1,
2,
3) do
end

Under ruby 1.9.1-p243: ["-", 8]

Under ruby 1.9.2-p136 and newer: ["-", 5]

It seems with newer versions of ruby, it reports it based on the line on which the function is called instead of where the actual block is. I believe the old behaviour is actually the correct behaviour.

Charlton

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0