Expand description
Panic Path Detection Linter (PROBAR-WASM-006)
Static analysis to detect panic-inducing patterns in WASM code.
§Motivation
In WASM, panic paths cause wasm_bindgen::throw_str which terminates
the entire WASM instance. Unlike native Rust where panics can be caught,
WASM panics are unrecoverable and break the user experience.
§Detection Rules
| Rule ID | Description | Severity |
|---|---|---|
| WASM-PANIC-001 | unwrap() call | Error |
| WASM-PANIC-002 | expect() call | Error |
| WASM-PANIC-003 | panic!() macro | Error |
| WASM-PANIC-004 | unreachable!() macro | Warning |
| WASM-PANIC-005 | todo!() macro | Error |
| WASM-PANIC-006 | unimplemented!() macro | Error |
| WASM-PANIC-007 | Index access without bounds check | Warning |
§Example
ⓘ
// BAD: Will panic in WASM
let value = some_option.unwrap();
// GOOD: Proper error handling
let value = some_option.ok_or(MyError::Missing)?;Structs§
- Panic
Path Summary - Summary of panic path analysis
- Panic
Path Visitor - AST visitor for detecting panic paths
Functions§
- lint_
panic_ paths - Lint source code for panic paths