From cd3a1fbee2d7921963b16ec6e172ee929ea9e873 Mon Sep 17 00:00:00 2001 From: Oskar Eichler Date: Fri, 28 Aug 2026 03:04:15 +0300 Subject: [PATCH 1/2] Use original identity for recursive inspection --- lib/ostruct.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ostruct.rb b/lib/ostruct.rb index a8763da..62200cf 100644 --- a/lib/ostruct.rb +++ b/lib/ostruct.rb @@ -390,10 +390,10 @@ def delete_field(name, &block) # def inspect ids = (Thread.current[InspectKey] ||= []) - if ids.include?(object_id) + if ids.include?(object_id!) detail = ' ...' else - ids << object_id + ids << object_id! begin detail = @table.map do |key, value| " #{key}=#{value.inspect}" From b42e90275edd93b7b95637feb25f93c789bac3d5 Mon Sep 17 00:00:00 2001 From: Oskar Eichler <62393985+OskarEichler@users.noreply.github.com> Date: Fri, 28 Aug 2026 14:56:14 +0300 Subject: [PATCH 2/2] test: cover OpenStruct field collision regression --- test/ostruct/test_ostruct.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/ostruct/test_ostruct.rb b/test/ostruct/test_ostruct.rb index 616f84d..8c870a2 100644 --- a/test/ostruct/test_ostruct.rb +++ b/test/ostruct/test_ostruct.rb @@ -439,4 +439,11 @@ def test_performance_warning ) end end + def test_inspect_with_object_id_field + child = OpenStruct.new(object_id: 1, value: 2) + parent = OpenStruct.new(object_id: 1, child: child) + + assert_match(/child=#/, parent.inspect) + end + end