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
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.
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.
Do you really like the old behavior? Line 8 points
the end of the block. I prefer the beginning (Line 7).
IOW, a result I expect is: ["-", 7]
The following patch works for me, and passes test-all,
though I'm not sure if the fix is right. I'll commit
it if there is no objection.
Do you really like the old behavior? Line 8 points
the end of the block. I prefer the beginning (Line 7).
IOW, a result I expect is: ["-", 7]
I think the old behaviour will point you to the first line after the do. I agree that line 7 would be better but at least line 8 is deterministic so either 7 or 8 would be preferable to 5.
The following patch works for me, and passes test-all,
though I'm not sure if the fix is right. I'll commit
it if there is no objection.
This issue was solved with changeset r35447.
Charlton, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
parse.y (primary): remove wrong "fixpos" that caused incorrect
source_location of blocks. [ruby-core:42232] [Bug #5930]