From a92a96fadb56067c3e550e7f55df4a76e60fdb27 Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Mon, 15 Dec 2025 13:19:56 +0100 Subject: [PATCH] Align treetab hash with equivalence (#25354) In particular, hash `typ` for `nkType`, `nkNilLit` or they end up generating collisions image --- compiler/treetab.nim | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/compiler/treetab.nim b/compiler/treetab.nim index 1fd539f0f2..b8b0f7b191 100644 --- a/compiler/treetab.nim +++ b/compiler/treetab.nim @@ -21,20 +21,13 @@ proc hashTree*(n: PNode): Hash = return result = ord(n.kind) case n.kind - of nkEmpty, nkNilLit, nkType: - discard - of nkIdent: - result = result !& n.ident.h - of nkSym: - result = result !& n.sym.id - of nkCharLit..nkUInt64Lit: - if (n.intVal >= low(int)) and (n.intVal <= high(int)): - result = result !& int(n.intVal) - of nkFloatLit..nkFloat64Lit: - if (n.floatVal >= - 1000000.0) and (n.floatVal <= 1000000.0): - result = result !& toInt(n.floatVal) - of nkStrLit..nkTripleStrLit: - result = result !& hash(n.strVal) + of nkEmpty: discard + of nkSym: result = result !& n.sym.id + of nkIdent: result = result !& n.ident.h + of nkCharLit..nkUInt64Lit: result = result !& hash(n.intVal) + of nkFloatLit..nkFloat64Lit: result = result !& hash(cast[uint64](n.floatVal)) + of nkStrLit..nkTripleStrLit: result = result !& hash(n.strVal) + of nkType, nkNilLit: result = result !& hash(n.typ.itemId) else: for i in 0..