mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
error.c: avoid infinite recursion at inspecting the frozen object
This commit is contained in:
parent
b2fe7484e7
commit
1624d77f3e
2 changed files with 35 additions and 7 deletions
|
@ -886,6 +886,21 @@ end.join
|
|||
obj.instance_variable_set(:@test, true)
|
||||
}
|
||||
assert_include(e.message, obj.inspect)
|
||||
|
||||
klass = Class.new do
|
||||
def init
|
||||
@x = true
|
||||
end
|
||||
def inspect
|
||||
init
|
||||
super
|
||||
end
|
||||
end
|
||||
obj = klass.new.freeze
|
||||
e = assert_raise_with_message(FrozenError, /can't modify frozen #{obj.class}/) {
|
||||
obj.init
|
||||
}
|
||||
assert_include(e.message, klass.inspect)
|
||||
end
|
||||
|
||||
def test_name_error_new_default
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue