Skip to content

Commit c892013

Browse files
authored
Improve validation error when component model feature not enabled (#939)
* Improve validation error when component model feature not enabled * Fix error message in test * Make sure the submodule is not empty * Improve error
1 parent cdbaae2 commit c892013

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

crates/wasmparser/src/validator.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,8 +534,9 @@ impl Validator {
534534
if !self.features.component_model {
535535
bail!(
536536
range.start,
537-
"unknown binary version: {num:#x}, \
538-
note: the WebAssembly component model feature is not enabled",
537+
"unknown binary version and encoding combination: {num:#x} and 0x1, \
538+
note: encoded as a component but the WebAssembly component model feature \
539+
is not enabled - enable the feature to allow component validation",
539540
);
540541
}
541542
if num == WASM_COMPONENT_VERSION {

tests/local/missing-features/component-not-enabled.wast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
"\00asm"
44
"\0a\00\01\00"
55
)
6-
"unknown binary version: 0xa, note: the WebAssembly component model feature is not enabled")
6+
"unknown binary version and encoding combination: 0xa and 0x1, note: encoded as a component but the WebAssembly component model feature is not enabled - enable the feature to allow component validation")

tests/roundtrip.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,12 @@ fn main() {
8787
/// then load up and test in parallel.
8888
fn find_tests() -> Vec<PathBuf> {
8989
let mut tests = Vec::new();
90-
if !Path::new("tests/testsuite").exists() {
90+
let test_suite = Path::new("tests/testsuite");
91+
if !test_suite.exists()
92+
|| std::fs::read_dir(test_suite)
93+
.map(|mut d| d.next().is_none())
94+
.unwrap_or(true)
95+
{
9196
panic!("submodules need to be checked out");
9297
}
9398
find_tests("tests/local".as_ref(), &mut tests);

0 commit comments

Comments
 (0)