diff options
author | Alon Zakai <azakai@google.com> | 2021-02-24 17:54:57 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-24 09:54:57 -0800 |
commit | 6656dfaf9c52b1dda3426b6d7e2a1db3ec3617e5 (patch) | |
tree | 6f2c8582ea0408774b90bd5495faf8ceb15a2561 /test/example/hash.cpp | |
parent | 49a906dc04f760a7eb32627689f6cc98524c0f72 (diff) | |
download | binaryen-6656dfaf9c52b1dda3426b6d7e2a1db3ec3617e5.tar.gz binaryen-6656dfaf9c52b1dda3426b6d7e2a1db3ec3617e5.tar.bz2 binaryen-6656dfaf9c52b1dda3426b6d7e2a1db3ec3617e5.zip |
Fix hashing of a use of a name without the context/target for it (#3601)
Before this we would assert on hashing e.g. (br $x) by itself, without the
context so we recognized the name $x. Somehow that was not an issue
until delegate, we just happened to not hash such things. I believe I remember
that @aheejin noticed this issue before, but given we didn't have a testcase,
we deferred fixing it - now is the time, I guess, as with delegate it is easy to
get e.g. CodeFolding to hash a Try with a delegate.
Issue found by emscripten-core/emscripten#13485
Diffstat (limited to 'test/example/hash.cpp')
-rw-r--r-- | test/example/hash.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/example/hash.cpp b/test/example/hash.cpp index 7c3882cc9..ba9ca24ea 100644 --- a/test/example/hash.cpp +++ b/test/example/hash.cpp @@ -138,5 +138,15 @@ int main() { y.index = 11; assertNotEqual(x, y); } + { + // It is ok to hash something that refers to an unknown name, like a break + // without the outside context that it branches to. And different names + // should have different hashes. + Break x; + x.name = "foo"; + Break y; + y.name = "bar"; + assertNotEqual(x, y); + } std::cout << "success.\n"; } |