diff options
| author | Henry <mail@henrygressmann.de> | 2026-07-14 17:33:43 +0200 |
|---|---|---|
| committer | Henry <mail@henrygressmann.de> | 2026-07-14 17:33:43 +0200 |
| commit | fe43e4816efbf622e8cdc106a552dfb9aadfb80e (patch) | |
| tree | b0d4f83e5baa76932d6a31bd401bb8525d58805d /crates/cli/src | |
| parent | 089f5dd1dd73701b83181011f6268f5c1bcbbb6b (diff) | |
fix: remove `_start` fallback for instantiation
Signed-off-by: Henry <mail@henrygressmann.de>
Diffstat (limited to 'crates/cli/src')
| -rw-r--r-- | crates/cli/src/cmd/run.rs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/crates/cli/src/cmd/run.rs b/crates/cli/src/cmd/run.rs index b2f5e03..06f29f1 100644 --- a/crates/cli/src/cmd/run.rs +++ b/crates/cli/src/cmd/run.rs @@ -1,4 +1,4 @@ -use eyre::{Result, bail}; +use eyre::Result; use tinywasm::types::ExportType; use tinywasm::{ModuleInstance, Store}; @@ -34,13 +34,17 @@ pub fn run(args: RunArgs) -> Result<()> { Ok(()) } None => { - if instance.start_func(&store)?.is_none() { - bail!( - "module has no start function or `_start` export; use `tinywasm inspect {module_path}` or `tinywasm run --invoke <export> {module_path}`" - ) + if instance.start_func(&store)?.is_some() { + let _ = instance.start(&mut store)?; + return Ok(()); } - let _ = instance.start(&mut store)?; + let start = instance.func_untyped(&store, "_start").map_err(|_| { + eyre::eyre!( + "module has no start function or `_start` export. Use `tinywasm inspect {module_path}` or `tinywasm run --invoke <export> {module_path}`" + ) + })?; + start.call(&mut store, &[])?; Ok(()) } } |
