diff options
author | Alon Zakai <azakai@google.com> | 2021-08-19 10:13:10 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-19 10:13:10 -0700 |
commit | f1aa78c022eb3f96a0d97e28ce9c35edbe7c45a1 (patch) | |
tree | b84d36b5ec21fc6760fed57dd2019e4a2f122a23 /src | |
parent | cb73700520fa34a58053835d2497c46f1da888c4 (diff) | |
download | binaryen-f1aa78c022eb3f96a0d97e28ce9c35edbe7c45a1.tar.gz binaryen-f1aa78c022eb3f96a0d97e28ce9c35edbe7c45a1.tar.bz2 binaryen-f1aa78c022eb3f96a0d97e28ce9c35edbe7c45a1.zip |
[Wasm GC] Nulls compare equal regardless of type (#4094)
Diffstat (limited to 'src')
-rw-r--r-- | src/wasm/literal.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/wasm/literal.cpp b/src/wasm/literal.cpp index c7a9ca844..8beae78bd 100644 --- a/src/wasm/literal.cpp +++ b/src/wasm/literal.cpp @@ -338,14 +338,17 @@ void Literal::getBits(uint8_t (&buf)[16]) const { } bool Literal::operator==(const Literal& other) const { + // The types must be identical, unless both are references - in that case, + // nulls of different types *do* compare equal. + if (type.isRef() && other.type.isRef() && (isNull() || other.isNull())) { + return isNull() && other.isNull(); + } if (type != other.type) { return false; } auto compareRef = [&]() { assert(type.isRef()); - if (isNull() || other.isNull()) { - return isNull() == other.isNull(); - } + // Note that we've already handled nulls earlier. if (type.isFunction()) { assert(func.is() && other.func.is()); return func == other.func; |