Static typechecker for Erlang based on set-theoretic types.
Try the playground to see how etylizer works for Erlang and Elixir code.
This is the development (dev) branch.
This branch is subject to rebases (dev and experimental are mutable). main is immutable.
Branches.
main: the stable release; always has the most up-to-date bug fixes.dev: not-yet-approved optimizations and community-approved to-be-tested features.experimental: novel type-level features to try out.
User-level documentation is work in progress.
Currently supported
makeorrebar3 escriptizewill generate a standalone portable escript calledetylizerinside the directory_build/default/binetylizer -hfor help- if etylizer is not on the current path, then prepend the folder where etylizer is located:
$PATH_TO_ETYLIZER/etylizer -h
- if etylizer is not on the current path, then prepend the folder where etylizer is located:
- To check a single module file
hello.erlexecuteetylizer hello.erl - To check a rebar project
hello.erl- compile the project (e.g.
rebar3 compile) - execute
etylizer -P . -S srcwhile in the root of the project
- compile the project (e.g.
Useful for debugging:
etylizer hello.erl --force -l debug -o foo/1
- type checks only the function
foo/1(-o) with additional debug information (-l) - disables caching of results, i.e. force type checking (
--force) - sets the verbosity of logging to
debug
There are two self-contained example projects to showcase native usage.
example_project/. A simple Erlang project. A tour of etylizer features (occurrence typing, intersection types, exhaustiveness checks, ...).example_project_elixir/. A simple Elixir project.
- Parse, using erlang's parser.
- Transform the AST into an internal representation. The AST for the internal representation
is somewhat simpler and has the following properties:
- All names of local variable are unique.
- Variable occurences have been resolved so that we know whether a variable occurrence introduces a new binding or refers to an existing binding and in which module the existing binding is defined.
- Bounds in type definitions have been replaced by intersections.
- It is stable and is used for caching.
- Perform several sanity checks
- Check that type defs are regular and contractive. This requires constructing a dependency cycle and potentially loading of type defs from other modules.
- Check that we have a type signature for all non-local functions. This requires loading type specs from external modules. We also need type spec for all bifs and for all erlang modules.
- Check that each top-level functions have a type spec.
- Generate constraint sets
- Solve them via
erlang_typestallying. - On error, try to locate the error location within a reasonable timeframe.
- Make sure every top-level function has a type annotation.
- Make sure every module has a short description at the top of the file stating the purpose of the module.
- Make sure that complicated functions have a short text of documentation.
- Make sure that complicated functions have unit tests.
- Make sure that all unit tests are running before comitting:
make test - Make sure the etylizer and dialyzer is happy before comitting:
make check