Repository navigation
D196 (#2372): HashMap[K, V, Minted] — an unseeded hasher for IDs the program minted; generic arity is checked - #3069
Merged
Merged
Conversation
added 3 commits
November 7, 2026 09:37
…er where it is declared `HashMap[K, V, Minted]` / `HashSet[T, Minted]` (std.collections.Minted): the runtime's key kind 3 hashes an integer ID with a folded multiply-mix, unseeded, because nothing outside the process chose it; the seed stays the default for every key type (D96). Sema's new validate_generic_arity refuses a wrong argument count for any declared generic (`HashMap[i32, i32, i32]` was accepted and miscompiled) and admits the hasher slot for an integer key only; a three-argument `Name[A, B, C]` in expression position is the type when its base names one. Both backends pass the kind at map creation. §11.7, changelog v7.41, decision log. tools/sweep_minted_maps.w adds the argument to a file's integer-keyed maps; the src/ sweep waits for a seed that knows Minted. Measured: a stage2 built from a swept src checks src/main.w in 98.7 s against 123.8 s unswept.
…e sweep tool enumerates its lines
…mma count is a bool cast
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
D196 (Eric, 2026-11-08, #2372): the per-process seed stays the default hasher for every key type (D96); a map or set whose keys are integer IDs the program minted names the unseeded hasher where it is declared, as a type:
HashMap[K, V, Minted],HashSet[T, Minted]. A multiply-mix, never identity; refused over a non-integer key; never chosen by key type. Iteration order is insertion order either way, so nothing about output or the fixpoint changes. Spec §11.7, changelog v7.41, decision log entry.Runtime (
rt/rt_core.w): the map's str flag becomes a key kind (HM_KEY_BYTES/STR/FNS/MINTED); kind 3 hashes withhm_hash_minted—k *% 0x9E3779B97F4A7C15, high half folded down, so the low bits the table indexes by get the mix (sequential IDs would cluster under identity; a bare product leaves the low bits as they were).Std:
std.collections.Minted, an empty marker type with the rule in its doc.Sema.
validate_generic_arity(new): a declared generic type refuses a wrong argument count.HashMap[i32, i32, i32]had been accepted and miscompiled (getfound nothing) because nothing checked arity for struct generics; the hasher slot is the one extension (HashMap's third, HashSet's second argument,Mintedonly, integer key only).setup_generic_inst_substitutionbindsimpl[K, V] HashMap[K, V]to the three-argument instance; the map-literal target and two MirLower collect targets accept "at least two".Name[A, B, C]in expression position parses as a multi-index; when its base names a type and every spec is a scalar, it is the type (multi_index_names_type, both type-level resolvers,check_multi_index, the static-receiver paths), soHashMap[i32, V, Minted].new()works asHashMap[K, V].new()does.Backends: both pass kind 3 at every map creation when the destination type names
Minted(map_type_is_minted/map_tid_is_minted).Fixtures:
behav_d196_minted_hasher.w(insert/get/remove/order/set/literal/constructor form),err_d196_minted_over_str_key.w,err_d196_hasher_names_other_type.w,err_generic_arity_list.w.Tool:
tools/sweep_minted_maps.wadds, Mintedto everyHashMap[i32|i64, …]/HashSet[i32|i64]in a file (Lexer, bracket-matched) and the import. Thesrc/sweep is not in this PR:src/is compiled by the pinned seed against the seed's std, which knows noMinted; it lands after the next seed. Before it does, every map's key provenance is reviewed (a map keyed by a parsed or received integer stays seeded).Measurement (a stage2 built from a swept scratch copy of
src/against the unswept one, both checking the samesrc/main.w, one run each, same machine):check src/main.wMinted)A fifth of the check, against the third the profile attributed to SipHash: the rest of that third is probe count and the hasher calls the swept maps still make through
hm_find_slot, which is the next thing to measure per the ruling.