Skip to content

Commit

Permalink
Check if RubyVM is defined before accessing it
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon authored and ko1 committed Dec 5, 2023
1 parent 685caf1 commit f1042b7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/debug/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def last_line
def first_line
self.to_a[4][:code_location][0]
end unless method_defined?(:first_line)
end
end if defined?(RubyVM::InstructionSequence)

module DEBUGGER__
PresetCommands = Struct.new(:commands, :source, :auto_continue)
Expand Down Expand Up @@ -133,7 +133,7 @@ def initialize
@commands = {}
@unsafe_context = false

@has_keep_script_lines = RubyVM.respond_to? :keep_script_lines
@has_keep_script_lines = defined?(RubyVM.keep_script_lines)

@tp_load_script = TracePoint.new(:script_compiled){|tp|
eval_script = tp.eval_script unless @has_keep_script_lines
Expand Down
2 changes: 1 addition & 1 deletion lib/debug/source_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def get iseq
end
end

if RubyVM.respond_to? :keep_script_lines
if defined?(RubyVM.keep_script_lines)
# Ruby 3.1 and later
RubyVM.keep_script_lines = true
require 'objspace'
Expand Down

0 comments on commit f1042b7

Please sign in to comment.