diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index 94d3b137699..0a1df50dbb9 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -4159,7 +4159,12 @@ void FunctionValidator::visitFunction(Function* curr) { curr->name, "all used types should be allowed"); - if (!curr->imported()) { + if (curr->imported()) { + shouldBeTrue( + curr->type.isInexact() || getModule()->features.hasCustomDescriptors(), + curr->name, + "exact imports require custom descriptors [--enable-custom-descriptors]"); + } else { shouldBeTrue( curr->type.isExact(), curr->name, "defined function should be exact"); } diff --git a/test/lit/validation/exact-import.wast b/test/lit/validation/exact-import.wast new file mode 100644 index 00000000000..318d397cfcb --- /dev/null +++ b/test/lit/validation/exact-import.wast @@ -0,0 +1,9 @@ +;; Test that exact imports require custom descriptors. + +;; RUN: not wasm-opt %s -all --disable-custom-descriptors 2>&1 | filecheck %s + +;; CHECK: exact imports require custom descriptors [--enable-custom-descriptors] + +(module + (import "" "" (func $f (exact))) +)