Skip to content

Commit 16ef22c

Browse files
committed
Update info c <exp> based on PR comment
This will now supress any errors during evaluation, still preventing the debugger from crashing. Instead it will now output the `not a Module` message only when the constant is defined.
1 parent f168b75 commit 16ef22c

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

lib/debug/thread_client.rb

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -607,12 +607,19 @@ def iter_consts c, names = {}
607607

608608
def get_consts expr = nil, only_self: false, &block
609609
if expr && !expr.empty?
610-
_self = frame_eval(expr)
611-
if M_KIND_OF_P.bind_call(_self, Module)
612-
iter_consts _self, &block
613-
return
610+
begin
611+
puts "this is hit"
612+
_self = frame_eval(expr, re_raise: true)
613+
rescue Exception => e
614+
puts "so it this"
615+
# ignore
614616
else
615-
puts "#{_self.inspect} (by #{expr}) is not a Module."
617+
if M_KIND_OF_P.bind_call(_self, Module)
618+
iter_consts _self, &block
619+
return
620+
else
621+
puts "#{_self.inspect} (by #{expr}) is not a Module."
622+
end
616623
end
617624
elsif _self = current_frame&.self
618625
cs = {}

test/console/info_test.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,6 @@ def test_info_constant_with_expression_errors
258258
type "info constants foo"
259259
assert_line_text([
260260
/eval error: undefined local variable or method `foo' for main/,
261-
/.*/,
262-
/nil \(by foo\) is not a Module./
263261
])
264262

265263
type "c"

0 commit comments

Comments
 (0)