Skip to content

Commit 06342cd

Browse files
committed
catch any exception on singletonclass
fix #1162
1 parent 2791573 commit 06342cd

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

lib/debug/frame_info.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def parameters_info
171171

172172
private def get_singleton_class obj
173173
obj.singleton_class # TODO: don't use it
174-
rescue TypeError
174+
rescue Exception
175175
nil
176176
end
177177

test/console/backtrace_test.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,4 +229,31 @@ def test_backtrace_prints_without_hanging
229229
end
230230
end
231231
end
232+
233+
class BrokenSingletonMethodBacktraceTest < ConsoleTestCase
234+
def program
235+
<<~RUBY
236+
1| class C
237+
2| def self.foo
238+
3| debugger
239+
4| end
240+
5| def singleton_class
241+
6| raise
242+
7| end
243+
8| def self.singleton_class
244+
9| eval(")") # SyntaxError
245+
10| end
246+
11| end
247+
12| C.foo
248+
RUBY
249+
end
250+
251+
def test_raise_exception
252+
debug_code program do
253+
type 'c'
254+
assert_line_text(/foo/)
255+
type 'c'
256+
end
257+
end
258+
end
232259
end

0 commit comments

Comments
 (0)