Actions
Bug #16334
closedWrong line numbers for multiline method chains
Description
I faced a strange distribution of line numbers in bytecode for multiline expressions like this:
class Test
def method1
self
end
def method2
self
end
def method3
true
end
end
def hello
Test.new #bp here
.method1 #bp here
.method2 #bp here
.method3 #bp here
end
2.3.7 bytecode:
== disasm: #<ISeq:hello@/home/viuignick/.RubyMine2019.2/config/scratches/scratch.rb>
0000 trace 8 ( 14)
0002 trace 1 ( 18)
0004 getinlinecache 11, <is:0> ( 15)
0007 getconstant :Test
0009 setinlinecache <is:0>
0011 opt_send_without_block <callinfo!mid:new, argc:0, ARGS_SIMPLE>, <callcache>( 16)
0014 opt_send_without_block <callinfo!mid:method1, argc:0, ARGS_SIMPLE>, <callcache>( 17)
0017 opt_send_without_block <callinfo!mid:method2, argc:0, ARGS_SIMPLE>, <callcache>( 18)
0020 opt_send_without_block <callinfo!mid:method3, argc:0, ARGS_SIMPLE>, <callcache>
0023 trace 16 ( 19)
0025 leave ( 18)
As you can see there is no trace line-event instuction for line №15, because of that debuggers will not stop there. Furthermore call of the method new
is on the line #16(actually 15), method method1 is on the line 17(actually 16), method2 is on the line 18 (actually 19)
2.5.4 bytecode
0000 getinlinecache 7, <is:0> ( 15)[LiCa]
0003 getconstant :Test
0005 setinlinecache <is:0>
0007 opt_send_without_block <callinfo!mid:new, argc:0, ARGS_SIMPLE>, <callcache>( 16)
0010 opt_send_without_block <callinfo!mid:method1, argc:0, ARGS_SIMPLE>, <callcache>( 17)
0013 opt_send_without_block <callinfo!mid:method2, argc:0, ARGS_SIMPLE>, <callcache>( 18)
0016 opt_send_without_block <callinfo!mid:method3, argc:0, ARGS_SIMPLE>, <callcache>
0019 leave ( 19)[Re]
The same situation to 2.5.*
for ruby versions > 2.5.0 work fine:
== disasm: #<ISeq:hello@/home/viuignick/.RubyMine2019.2/config/scratches/scratch.rb:14 (14,0)-(19,3)> (catch: FALSE)
0000 opt_getinlinecache 7, <is:0> ( 15)[LiCa]
0003 getconstant :Test
0005 opt_setinlinecache <is:0>
0007 opt_send_without_block <callinfo!mid:new, argc:0, ARGS_SIMPLE>, <callcache>
0010 opt_send_without_block <callinfo!mid:method1, argc:0, ARGS_SIMPLE>, <callcache>( 16)
0013 opt_send_without_block <callinfo!mid:method2, argc:0, ARGS_SIMPLE>, <callcache>( 17)
0016 opt_send_without_block <callinfo!mid:method3, argc:0, ARGS_SIMPLE>, <callcache>( 18)
0019 leave ( 19)[Re]
Actions
Like0
Like0Like0Like0