[ruby/irb] Use InstructionSequence#script_lines to get method source

(https://github.com/ruby/irb/pull/1005)

It works with both prism and parse.y

https://github.com/ruby/irb/commit/bcfaa72d5a
This commit is contained in:
tomoya ishida 2024-09-17 02:36:21 +09:00 committed by git
parent 1c3981cb88
commit 6c4ce72609

View File

@ -100,7 +100,7 @@ module IRB
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