From ea7e4cf0b9b730fee9686086e524d6c2dfa51750 Mon Sep 17 00:00:00 2001 From: Kevin Tang <73975146+vt128@users.noreply.github.com> Date: Tue, 10 Nov 2026 01:51:00 +0800 Subject: [PATCH] [doc] Explain distinct hash collisions and integer workaround Refs LET-45 / LOCAL-046. Document the current hash-only limitation without claiming the pending equality fix is merged. --- lib/goidiomatic/README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/goidiomatic/README.md b/lib/goidiomatic/README.md index 061352d..a756197 100644 --- a/lib/goidiomatic/README.md +++ b/lib/goidiomatic/README.md @@ -317,6 +317,15 @@ Removes duplicates, preserving first-seen order. Returns a **list** for a list o A mutable list input remains mutable after the call, including when an element cannot be hashed. +**Known limitation:** `distinct` currently compares hashes alone, so unequal values with the same hash can be dropped: `distinct([1, 4294967297])` returns `[1]`. The equality fix in [#198](https://github.com/1set/starlet/pull/198) is not merged. For native integers, a Starlark dict compares keys and preserves first-seen order: + +```python +values = [1, 4294967297, 1] +unique = {value: None for value in values}.keys() +print(unique) +# Output: [1, 4294967297] +``` + ```python load("go_idiomatic", "distinct") print(distinct([1, 2, 2, 3, 3, 3]), distinct((1, 2, 2, 3)))