erl_lint(3erl)
π erl_lint β the Erlang code linter β¨
okay so bestie, welcome to erl_lint(3erl) from the Erlang Module Definition docs β this is the page for the Erlang code linter, and honestly it's lowkey the vibe check of the whole compiler. π
π NAME π
erl_lint β the Erlang code linter. that's it, that's the whole name, periodt.
π¦ DESCRIPTION π¦
so this module is literally the one that checks your Erlang code for illegal syntax and other bugs, and it also warns you about coding practices that are just... not recommended. it's giving very much "your friend who reads your essay before you submit it" energy. π«Ά
the errors it detects include:
- redefined and undefined functions
- unbound and unsafe variables
- illegal record use
the warnings it detects include:
- unused functions and imports
- unused variables
- variables imported into matches
- variables exported from
if/case/receive - variables shadowed in funs and list comprehensions
some of these warnings are totally optional and can be turned on by passing the appropriate option, which is described down below. iykyk. β¨
oh and also β the functions in this module get invoked automatically by the Erlang compiler. so unless you've written your own Erlang compiler (main character energy, honestly π), there is literally no reason to invoke these functions separately.
πΈ DATA TYPES πΈ
error_info() =
{erl_anno:location() | none, module(), error_description()}
error_description() = term()
that's the tea. moving on. π
π EXPORTS π
β format_error(ErrorDescriptor) -> io_lib:chars()
Types:
ErrorDescriptor = error_description()
takes an ErrorDescriptor and returns a string that describes the error or warning. this one is usually called implicitly when processing an ErrorInfo structure (peep the section on Error Information below π).
π§ is_guard_test(Expr) -> boolean()
Types:
Expr = erl_parse:abstract_expr()
tests whether Expr is a legal guard test. Expr is an Erlang term representing the abstract form for the expression. and bestie, erl_parse:parse_exprs(Tokens) can be used to generate a list of Expr. slay. β¨
π module(AbsForms) -> {ok, Warnings} | {error, Errors, Warnings}
module(AbsForms, FileName) ->
{ok, Warnings} | {error, Errors, Warnings}
module(AbsForms, FileName, CompileOptions) ->
{ok, Warnings} | {error, Errors, Warnings}
Types:
AbsForms = [erl_parse:abstract_form() | erl_parse:form_info()]
FileName = atom() | string()
CompileOptions = [compile:option()]
Warnings = Errors = [{SourceFile, [ErrorInfo]}]
SourceFile = file:filename()
ErrorInfo = error_info()
checks all the forms in a module for errors. it returns:
{ok,Warnings}β there are no errors in the module. π{error,Errors,Warnings}β there are errors in the module. π
okay so about the options controlling the warnings β this module is of interest only to the maintainers of the compiler, and to avoid the same description living in two places, the elements of Options that control the warnings are only described in the compile(3erl) module. so go look there, bestie, i don't make the rules. π«Ά
AbsForms of a module comes from a file that's read through epp, the Erlang preprocessor, and it can come from many files. which means any references to errors have to include the filename β see the epp(3erl) module or the parser (check the erl_parse(3erl) module). the returned errors and warnings have this format:
[{SourceFile,[ErrorInfo]}]
and the errors and warnings are listed in the order in which they're encountered in the forms. so the errors from one file can be split into different entries in the list of errors. no cap, that's just how it do. π
π ERROR INFORMATION π
ErrorInfo is the standard ErrorInfo structure that gets returned from all I/O modules. the format is literally:
{ErrorLine, Module, ErrorDescriptor}
and a string describing the error is obtained with this call right here:
Module:format_error(ErrorDescriptor)
that's the whole ritual. π
π SEE ALSO π
okay that's the page!! go forth and lint, bestie πΈ
and finally, the cute little sign-off at the bottom of the original: this one's from Ericsson AB, for stdlib 4.3.1.3 β erl_lint(3erl). mwah. π
π¦ where this page comes from
- ubuntu noble: erlang-manpages 1:25.3.2.8+dfsg-1ubuntu4 Β· Apache-2.0
- ubuntu noble: erlang-manpages 1:25.3.2.8+dfsg-1ubuntu4.8 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms