Repeat membership and equality ignore the sequence size
Author: xu91102Created Sep 26, 2026Updated Sep 26, 2026
Repeat's optimized membership and equality checks ignore its size.
On current main:
Repeat('empty', 0).includes('empty') // true, expected false
Repeat('a', 2).equals(Repeat('a', 3)) // true, expected false
Repeat('a', 2).equals(Repeat('a')) // true, expected falseThis disagrees with the represented sequence and can cause equality-based change detection to miss a changed repetition count. Empty Repeat instances are cached, so the value incorrectly reported as included also depends on the first empty instance constructed.
Reproduced with source tests on Node 22.23.2, macOS. Prepared with Codex assistance; both regression tests fail on the original implementation.
Source: immutable-js/immutable-js