bytecodealliance / wasm-tools

CLI and Rust libraries for low-level manipulation of WebAssembly modules
Apache License 2.0
1.36k stars 245 forks source link

Add an assert to wit-parser's `assert_valid`. #1908

Closed sunfishcode closed 1 week ago

sunfishcode commented 1 week ago

Indexmap's MutableKeys trait allows one to mutate the keys in an IndexMap, however it doesn't prevent bugs where the new keys have different hash values from the old keys. Since I recently made this mistake, add an assert to help catch such bugs. It doesn't always catch the bug, because whether or not the bug is observable depends on hashmap internals, but it's better than nothing.