Project

General

Profile

Actions

Bug #18804

open

Invalid line number for putnil instruction

Added by hurricup (Alexandr Evstigneev) over 2 years ago. Updated over 2 years ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:108693]

Description

Looks like this is a pretty old bug. Consider example:

def foo1
  if true
    nil
  else
    1
  end
end

def foo2
  if true
    42
  else
    1
  end
end

foo1_method = method(:foo1)
puts RubyVM::InstructionSequence.of(foo1_method).disasm

foo2_method = method(:foo2)
puts RubyVM::InstructionSequence.of(foo2_method).disasm

Gives us:

== disasm: #<ISeq:foo1@/home/hurricup/RubymineProjects/untitled28/test.rb:1 (1,0)-(7,3)> (catch: FALSE)
0000 putnil                                                           (   2)[LiCa]
0001 leave                                                            (   7)[Re]
== disasm: #<ISeq:foo2@/home/hurricup/RubymineProjects/untitled28/test.rb:9 (9,0)-(15,3)> (catch: FALSE)
0000 putobject                              42                        (  11)[LiCa]
0002 leave                                                            (  15)[Re]

putnil has line set to 2 (and it should be 3)
putobject 42 has line set to 11 and this is correct one.

User unable to put a breakpoint to the nil in debugger because of this.

Actions

Also available in: Atom PDF

Like0
Like0