You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
HashMap and HashSet hash and compare a key by its bytes: two equal keys holding a str are two entries #2180
§11.7 / §11.8 (Eq, Hash), D95 (structural types derive). Found implementing #2161 on main cbcbd51.
The runtime map (rt/rt_core.whm_hash_key, hm_keys_eq) hashes and compares a key by its bytes unless the key is exactly str. Every other key that owns or views memory is compared by address:
The same for a tuple key (i32, str) and an Option[str] key (both print 2). A user impl Eq/impl Hash is never called either. Floats are wrong the same way (-0.0 == 0.0, different bytes).
Expected: a key is hashed by its Hash and compared by its Eq (#2137 made == structural; the map was left behind). Plan: the compiler passes per-key-type hash and equality functions to a new with_hashmap_new_keyed; a key whose bytes are its value (integers, bools, plain enums, records of those) keeps the byte path.
Worse than byte comparison: with_hashmap_new marks every 16-byte key as a str (hm_set_is_str_key(mi, if key_size == 16: 1 else: 0)), so HashSet[(i64, i64)] reads the first integer as a pointer. s.insert((5, 3)) exits with SIGSEGV (rc 139) on main cbcbd51.
Activity
ehartford commentedon Oct 5, 2026
Worse than byte comparison:
with_hashmap_newmarks every 16-byte key as astr(hm_set_is_str_key(mi, if key_size == 16: 1 else: 0)), soHashSet[(i64, i64)]reads the first integer as a pointer.s.insert((5, 3))exits with SIGSEGV (rc 139) on main cbcbd51.spec v7.25 (D96): a key is any structurally comparable value; a key p…
D95 + D96: let _ drops; pub const takes its value's type; ?? below |>…
ehartford commentedon Oct 5, 2026
Fixed on main by stack #2196 (merged as efb765c), battery green on a21e326; the regression test for it landed with the fix.
emitc 983 (#2812)