Skip to content

Commit f1042b7

Browse files
eregonko1
authored andcommitted
Check if RubyVM is defined before accessing it
1 parent 685caf1 commit f1042b7

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/debug/session.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def last_line
8282
def first_line
8383
self.to_a[4][:code_location][0]
8484
end unless method_defined?(:first_line)
85-
end
85+
end if defined?(RubyVM::InstructionSequence)
8686

8787
module DEBUGGER__
8888
PresetCommands = Struct.new(:commands, :source, :auto_continue)
@@ -133,7 +133,7 @@ def initialize
133133
@commands = {}
134134
@unsafe_context = false
135135

136-
@has_keep_script_lines = RubyVM.respond_to? :keep_script_lines
136+
@has_keep_script_lines = defined?(RubyVM.keep_script_lines)
137137

138138
@tp_load_script = TracePoint.new(:script_compiled){|tp|
139139
eval_script = tp.eval_script unless @has_keep_script_lines

lib/debug/source_repository.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def get iseq
2222
end
2323
end
2424

25-
if RubyVM.respond_to? :keep_script_lines
25+
if defined?(RubyVM.keep_script_lines)
2626
# Ruby 3.1 and later
2727
RubyVM.keep_script_lines = true
2828
require 'objspace'

0 commit comments

Comments
 (0)