From bcfaa72d5a6e1d59d59f2feef77e9dc553350b25 Mon Sep 17 00:00:00 2001 From: tomoya ishida Date: Tue, 17 Sep 2024 02:36:21 +0900 Subject: [PATCH] Use InstructionSequence#script_lines to get method source (#1005) It works with both prism and parse.y --- lib/irb/source_finder.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/irb/source_finder.rb b/lib/irb/source_finder.rb index 5d7d729d1..c515da570 100644 --- a/lib/irb/source_finder.rb +++ b/lib/irb/source_finder.rb @@ -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