A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
Add support for more `*.wast` syntax (#13042)
Alex Crichton4364d38192d4
diff --git a/crates/wast/src/wast.rs b/crates/wast/src/wast.rsindex 2dfc07ee66..86e8622632 100644--- a/crates/wast/src/wast.rs+++ b/crates/wast/src/wast.rs@@ -19,7 +19,7 @@ pub struct WastContext {/// recently defined.current: Option<InstanceKind>,core_linker: Linker<()>,- modules: HashMap<String, ModuleKind>,+ modules: HashMap<Option<String>, ModuleKind>,#[cfg(feature = "component-model")]component_linker: component::Linker<()>,@@ -645,18 +645,16 @@ impl WastContext {line: _,} => {let module = self.module_definition(&file)?;- if let Some(name) = name {- self.modules.insert(name.to_string(), module);- }+ self.modules.insert(name.map(|s| s.to_string()), module);}ModuleInstance {instance,module,line: _,} => {- let module = module- .as_deref()- .and_then(|n| self.modules.get(n))+ let module = self+ .modules+ .get(&module.as_ref().map(|s| s.to_string())).cloned().ok_or_else(|| format_err!("no module named {module:?}"))?;self.module(instance.as_deref(), &module)?;diff --git a/tests/misc_testsuite/wast-syntax.wast b/tests/misc_testsuite/wast-syntax.wastnew file mode 100644index 0000000000..f3a75e5df1--- /dev/null+++ b/tests/misc_testsuite/wast-syntax.wast@@ -0,0 +1,5 @@+(module definition (func (export "f")))+(module instance)++(invoke "f")+(assert_return (invoke "f"))