Skip to content

Replace panics with errors for unsupported heap type conversions#195

Merged
fibonacci1729 merged 2 commits intobytecodealliance:mainfrom
sumleo:fix/heap-type-unsupported-panic
Feb 17, 2026
Merged

Replace panics with errors for unsupported heap type conversions#195
fibonacci1729 merged 2 commits intobytecodealliance:mainfrom
sumleo:fix/heap-type-unsupported-panic

Conversation

@sumleo
Copy link
Contributor

@sumleo sumleo commented Feb 12, 2026

Summary

  • From<wasmparser::HeapType> panicked on shared heap types and used todo!() for exact heap types
  • Converted the entire chain of From impls to TryFrom so unsupported types produce proper errors instead of crashing at runtime:
    • HeapType: From<wasmparser::HeapType>TryFrom
    • CoreRefType: From<wasmparser::RefType>TryFrom
    • CoreType: From<wasmparser::ValType>TryFrom
    • CoreExtern: From<wasmparser::TableType>TryFrom
    • CoreExtern: From<wasmparser::GlobalType>TryFrom
  • Updated all call sites in package.rs to propagate errors via try_into()

Test plan

  • Added heap_type_conversion.rs integration tests: shared_heap_type_returns_error, exact_heap_type_returns_error, non_shared_heap_type_succeeds
  • All existing tests pass (cargo test --workspace)

The From<wasmparser::HeapType> impl panicked on shared heap types and
used todo!() for exact heap types. Converted the entire chain of From
impls to TryFrom (HeapType, RefType, CoreType, and the Table/Global
CoreExtern conversions) so that unsupported types produce proper errors
instead of crashing at runtime.

Updated all call sites in package.rs to propagate errors via try_into.
Added tests verifying that shared and exact heap types return errors.
@fibonacci1729 fibonacci1729 merged commit 4f9043f into bytecodealliance:main Feb 17, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants