From b24af444302896243ef9566263af8f352bf23266 Mon Sep 17 00:00:00 2001 From: Alexander Momchilov Date: Wed, 3 Jan 2024 21:09:54 -0500 Subject: [PATCH] Fix edge case for falsy values --- lib/debug/server_cdp.rb | 4 +++- lib/debug/server_dap.rb | 6 ++++-- test/protocol/step_back_raw_dap_test.rb | 6 +++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/debug/server_cdp.rb b/lib/debug/server_cdp.rb index 9958c71e2..9de276c7f 100644 --- a/lib/debug/server_cdp.rb +++ b/lib/debug/server_cdp.rb @@ -1114,7 +1114,9 @@ def process_cdp args when :properties oid = args.shift - if obj = @obj_map[oid] + if @obj_map.key?(oid) + obj = @obj_map[oid] + members = if Array === obj VariableInspector.new.indexed_members_of(obj, start: 0, count: obj.size) else diff --git a/lib/debug/server_dap.rb b/lib/debug/server_dap.rb index f0a6117d3..6edde3746 100644 --- a/lib/debug/server_dap.rb +++ b/lib/debug/server_dap.rb @@ -869,8 +869,10 @@ def process_dap args event! :protocol_result, :scope, req, variables: vars, tid: self.id when :variable vid = args.shift - obj = @var_map[vid] - if obj + + if @var_map.key?(vid) + obj = @var_map[vid] + members = case req.dig('arguments', 'filter') when 'indexed' VariableInspector.new.indexed_members_of( diff --git a/test/protocol/step_back_raw_dap_test.rb b/test/protocol/step_back_raw_dap_test.rb index eee84d8e2..413a6cda6 100644 --- a/test/protocol/step_back_raw_dap_test.rb +++ b/test/protocol/step_back_raw_dap_test.rb @@ -883,7 +883,7 @@ def test_step_back_works_correctly namedVariables: /\d+/, indexedVariables: 0, expensive: false, - variablesReference: 11 + variablesReference: 12 }, { name: "Global variables", @@ -917,7 +917,7 @@ def test_step_back_works_correctly name: "%self", value: "Foo", type: "Module", - variablesReference: 12, + variablesReference: 13, indexedVariables: 0, namedVariables: /\d+/ }, @@ -925,7 +925,7 @@ def test_step_back_works_correctly name: "bar", value: "nil", type: "NilClass", - variablesReference: 13, + variablesReference: 14, indexedVariables: 0, namedVariables: /\d+/ }