Skip to content

Commit

Permalink
Use InstructionSequence#script_lines to get method source (#1005)
Browse files Browse the repository at this point in the history
It works with both prism and parse.y
  • Loading branch information
tompng authored Sep 16, 2024
1 parent f256d78 commit bcfaa72
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/irb/source_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def find_source(signature, super_level = 0)
Source.new(file, line)
elsif method
# Method defined with eval, probably in IRB session
source = RubyVM::AbstractSyntaxTree.of(method)&.source rescue nil
source = RubyVM::InstructionSequence.of(method)&.script_lines&.join rescue nil
Source.new(file, line, source)
end
rescue EvaluationError
Expand Down

0 comments on commit bcfaa72

Please sign in to comment.