Description
DispatchDoctor is a Julia package that checks your code for type instability. You add the @stable macro to a function, a block, a module or an anonymous function, and it raises an error whenever a function's return type is not stable. The README says type-stable code should compile the check away, so it adds no runtime cost in that case, though it notes this may not always hold and suggests verifying with @code_llvm. You can switch the check off for a scope with @unstable, allow instability inside an allow_unstable context, or change the default mode from error to warn or disable. Packages that depend on DispatchDoctor can override the mode for their users with a dispatch_doctor_mode key in LocalPreferences.toml. The README also covers using the package inside other packages and a few special cases, such as wrapping modules and working in the REPL. It is aimed at Julia developers who care about performance and want an early warning when a function stops being type stable.…
Highlights
- @stable macro that enforces type-stable return values
- Error, warn or disable modes by default
- Scoped checks with @stable and @unstable blocks
- Per-package override through LocalPreferences.toml
- Works on functions, blocks, modules and anonymous functions
Ratings & Reviews
No ratings yet
Be the first to rate DispatchDoctor.jl.
People also visit

typescript-magician
Designs complex generic types, refactors `any` types to strict alternatives
DispatchDoctor.jl FAQ
What does DispatchDoctor do?
It is a Julia package with a @stable macro that raises an error when a function returns a type that is not stable, so type instability is caught early.
How do I turn the checks off?
Wrap code in @unstable to disable it for that scope, or set default_mode to disable or warn instead of the default error.
Does the check slow my code down?
The README says type-stable code should compile the check away, so there is no runtime cost in that case. It warns this may not always be true and suggests checking with @code_llvm.
Can a package change the mode for its users?
Yes. A dispatch_doctor_mode key in LocalPreferences.toml, typically set with Preferences.jl, overrides the mode locally or globally.
Where is the source code?
The package is public on GitHub at MilesCranmer/DispatchDoctor.jl.
What are the best DispatchDoctor.jl alternatives?
Popular alternatives to DispatchDoctor.jl include Revise.jl, Digma and React Doctor. See all DispatchDoctor.jl alternatives









