https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112011-12-08T15:27:23ZRuby Issue Tracking SystemRuby master - Bug #5614: Proc#source_location & #inspect shows wrong line number when chainedhttps://redmine.ruby-lang.org/issues/5614?journal_id=226502011-12-08T15:27:23Ztechnohippy (Yasushi ANDO)andyjpn@gmail.com
<ul></ul><p>It may not a bug but a specification. A block returns the number of a line in which the block is defined for its "source_location." When you use procs instead of blocks, it returns the values you expected.</p>
<p>Code:<br>
1 require 'pp'<br>
2 class Foo<br>
3 def bar(&blk)<br>
4 pp blk.source_location<br>
5 self<br>
6 end<br>
7 end<br>
8<br>
9 Foo.new.bar(&proc{<br>
10 puts 'b1'<br>
11 }).bar(&proc{<br>
12 puts 'b2'<br>
13 })</p>
<p>Result:<br>
$ ruby procs.rb<br>
["procs.rb", 9]<br>
["procs.rb", 11]</p> Ruby master - Bug #5614: Proc#source_location & #inspect shows wrong line number when chainedhttps://redmine.ruby-lang.org/issues/5614?journal_id=227882011-12-14T00:01:28Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li></ul><p>This issue was solved with changeset r34031.<br>
TzeYang, thank you for reporting this issue.<br>
Your contribution to Ruby is greatly appreciated.<br>
May Ruby be with you.</p>
<hr>
<ul>
<li>parse.y (primary): point method name line. <a href="/issues/5614">[ruby-core:40936]</a><br>
[Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: Proc#source_location & #inspect shows wrong line number when chained (Closed)" href="https://redmine.ruby-lang.org/issues/5614">#5614</a>]</li>
</ul>