summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-binary.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm/wasm-binary.cpp')
-rw-r--r--src/wasm/wasm-binary.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index 73718e636..21842e19b 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -7042,6 +7042,7 @@ bool WasmBinaryReader::maybeVisitSIMDLoadStoreLane(Expression*& out,
}
void WasmBinaryReader::visitSelect(Select* curr, uint8_t code) {
+ Type annotated = Type::none;
if (code == BinaryConsts::SelectWithType) {
size_t numTypes = getU32LEB();
std::vector<Type> types;
@@ -7052,15 +7053,15 @@ void WasmBinaryReader::visitSelect(Select* curr, uint8_t code) {
}
types.push_back(t);
}
- curr->type = Type(types);
+ annotated = Type(types);
}
curr->condition = popNonVoidExpression();
curr->ifFalse = popNonVoidExpression();
curr->ifTrue = popNonVoidExpression();
- if (code == BinaryConsts::SelectWithType) {
- curr->finalize(curr->type);
- } else {
- curr->finalize();
+ curr->finalize();
+ if (code == BinaryConsts::SelectWithType &&
+ !Type::isSubType(curr->type, annotated)) {
+ throwError("select type does not match annotation");
}
}