summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-validator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r--src/wasm/wasm-validator.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index 8ff2fb9b8..d6c6e7bd0 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -806,6 +806,12 @@ void FunctionValidator::visitFunction(Function* curr) {
shouldBeTrue(breakTargets.empty(), curr->body, "all named break targets must exist");
returnType = unreachable;
labelNames.clear();
+ // if function has a named type, it must match up with the function's params and result
+ if (info.validateGlobally && curr->type.is()) {
+ auto* ft = getModule()->getFunctionType(curr->type);
+ shouldBeTrue(ft->params == curr->params, curr->name, "function params must match its declared type");
+ shouldBeTrue(ft->result == curr->result, curr->name, "function result must match its declared type");
+ }
// expressions must not be seen more than once
struct Walker : public PostWalker<Walker, UnifiedExpressionVisitor<Walker>> {
std::unordered_set<Expression*>& seen;