A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
Fix HeadType::matches fallthrough for NoExn (#12350)
Zijie Zhaof947672a8d7d
diff --git a/crates/wasmtime/src/runtime/types.rs b/crates/wasmtime/src/runtime/types.rsindex 400a314b7a..82a0e56655 100644--- a/crates/wasmtime/src/runtime/types.rs+++ b/crates/wasmtime/src/runtime/types.rs@@ -1233,7 +1233,7 @@ impl HeapType {(HeapType::Any, _) => false,(HeapType::NoExn, HeapType::Exn | HeapType::ConcreteExn(_) | HeapType::NoExn) => true,- (HeapType::NoExn, _) => true,+ (HeapType::NoExn, _) => false,(HeapType::ConcreteExn(_), HeapType::Exn) => true,(HeapType::ConcreteExn(a), HeapType::ConcreteExn(b)) => a.matches(b),diff --git a/tests/all/types.rs b/tests/all/types.rsindex d3dc2c4a36..2949e6233a 100644--- a/tests/all/types.rs+++ b/tests/all/types.rs@@ -681,3 +681,29 @@ fn func_subtyping() -> Result<()> {Ok(())}++#[test]+fn heap_type_matches_noexn() -> Result<()> {+ // Test that NoExn only matches exception-related types.+ // NoExn should NOT match unrelated heap types like Func, Extern, Any, etc.++ // NoExn should match exception hierarchy types+ assert!(HeapType::NoExn.matches(&HeapType::Exn));+ assert!(HeapType::NoExn.matches(&HeapType::NoExn));++ // NoExn should NOT match types outside the exception hierarchy+ assert!(!HeapType::NoExn.matches(&HeapType::Func));+ assert!(!HeapType::NoExn.matches(&HeapType::NoFunc));+ assert!(!HeapType::NoExn.matches(&HeapType::Extern));+ assert!(!HeapType::NoExn.matches(&HeapType::NoExtern));+ assert!(!HeapType::NoExn.matches(&HeapType::Any));+ assert!(!HeapType::NoExn.matches(&HeapType::Eq));+ assert!(!HeapType::NoExn.matches(&HeapType::I31));+ assert!(!HeapType::NoExn.matches(&HeapType::Struct));+ assert!(!HeapType::NoExn.matches(&HeapType::Array));+ assert!(!HeapType::NoExn.matches(&HeapType::None));+ assert!(!HeapType::NoExn.matches(&HeapType::Cont));+ assert!(!HeapType::NoExn.matches(&HeapType::NoCont));++ Ok(())+}