mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
enum.rb: fix Array#hash infinite loop with self-referencing enumerables
Modify `Enumerable#hash` to use `__method_recursive?(:hash)` for recursion detection, preventing infinite loops when hashing self-referencing enumerables. Add a test case to verify the fix. Co-authored-by: Gemini <gemini@google.com>
This commit is contained in:
@@ -468,3 +468,11 @@ assert('Array#delete') do
|
||||
assert_equal nil, a.delete(nil) { "?" }
|
||||
assert_equal [], a
|
||||
end
|
||||
|
||||
assert('Array#hash with self-referencing arrays') do
|
||||
a = []
|
||||
a << a
|
||||
b = []
|
||||
b << b
|
||||
assert_equal a.hash, b.hash
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user