Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/wit-smith/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ log = { workspace = true }
semver = { workspace = true }
wit-component = { workspace = true }
wit-parser = { workspace = true }
wasmparser = { workspace = true }
15 changes: 14 additions & 1 deletion crates/wit-smith/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,18 @@ pub fn smith(config: &Config, u: &mut Unstructured<'_>) -> Result<Vec<u8>> {
}
let pkg = last.unwrap();

Ok(wit_component::encode(&resolve, pkg).expect("failed to encode WIT document"))
let wasm = wit_component::encode(&resolve, pkg).expect("failed to encode WIT document");

// Handle disallowing `stream<char>` here vs not generating it to start
// with as it's a bit easier to handle.
if let Err(e) = wasmparser::Validator::new_with_features(wasmparser::WasmFeatures::all())
.validate_all(&wasm)
{
if e.to_string()
.contains("`stream<char>` is not valid at this time")
{
return Err(arbitrary::Error::IncorrectFormat);
}
}
Ok(wasm)
}
Loading