W0059: Unavailable Type
Error
-module(main).
-spec foo() -> dep:nonexistent_type().
%% ^^^^^^^^^^^^^^^^^^^^^^ warning: W0059: Type 'dep:nonexistent_type/0' is not available through dependencies.
foo() -> ok.
Explanation
This diagnostic warns you when your code references a type that either:
- Does not exist (is undefined)
- Is not accessible because it's from a module outside your application's dependencies
- Exists but is not exported from the defining module
What This Diagnostic Checks
The diagnostic examines:
- Type specifications (
-specattributes) - Type definitions (
-typeand-opaqueattributes) - Callback specifications (
-callbackattributes)
Which Dependencies Count
A type reference is erased at compile time, so it needs the defining
application's source to be visible to the analysis, not its beam to be loadable
at runtime. The reachable set is therefore wider than the one
unavailable_function (W0085) uses for calls: alongside applications and
included_applications, an application declared in distributed_dependencies
counts as reachable. That relation describes an application reached over the
network, so it carries no build-system edge and — unlike applications — is
allowed to be cyclic.
Reachability is transitive across both kinds of edge, so declaring an
application in distributed_dependencies also makes everything that
application depends on reachable.
How to Fix
- Check if the type actually exists
- Verify the name and arity of the type
- Add the application that defines the type to your application's dependencies or move the type definition to an application that is already a dependency