numericKey returns the canonical hash contribution for a CEL numeric value. Int, Uint, and Double all funnel through float64 because CEL numeric equality is heterogeneous and exact: any Int/Uint/Double values that compare equal convert to identical float64 bits. Values above 2^53 lose precision and
(d float64)
| 161 | // identical float64 bits. Values above 2^53 lose precision and may share a bucket, |
| 162 | // which is benign — findInBucket resolves it. |
| 163 | func numericKey(d float64) uint64 { |
| 164 | if math.IsNaN(d) { |
| 165 | // matches treats NaN as equal to NaN for dispatch purposes, so collapse all |
| 166 | // payloads onto one quiet-NaN pattern. |
| 167 | return 0x7ff8000000000000 |
| 168 | } |
| 169 | if d == 0 { |
| 170 | // Normalizes -0.0, which CEL equality treats as 0.0. |
| 171 | return 0 |
| 172 | } |
| 173 | return math.Float64bits(d) |
| 174 | } |
| 175 | |
| 176 | func hashArg(arg ref.Val) uint64 { |
| 177 | switch v := arg.(type) { |