module.beam: Module name 'madule' does not match file name 'module'
The module name you’ve entered in the -module attribute doesn’t match the filename.
./module.erl:2: Warning: function some_function/0 is unused
You have not exported a function, or the place where it’s used has thewrong name or arity. It’s also possible you’ve written a function that isno longer needed. Check your code!
./module.erl:2: function some_function/1 undefined
The function does not exist. You’ve written the wrong name or arity either in the -export attribute or when declaring the function. This error is also output when the given function could not be compiled, usually because of a syntax error like forgetting to end a function with a period.
This happens for a variety of reasons. Common causes are unclosed parentheses, tuples, or wrong expression termination (like closing the last branch of a case with a comma). Other reasons include the use of a reserved atom in your code and Unicode characters not being con-verted correctly between different encodings (I’ve seen it happen!).
./module.erl:5: syntax error before:
This message is certainly not as descriptive as the previous one. It usually comes up when your line termination is not correct. This is a specific case of the previous error, so just keep an eye out.
./module.erl:5: Warning: this expression will fail with a 'badarith' exception
Erlang is all about dynamic typing, but remember that the types are strong. In this case, the compiler is smart enough to find that one of your arithmetic expressions will fail (say, llama + 5). It won’t find type errors much more complex than that, though.
./module.erl:5: Warning: variable 'Var' is unused
You declared a variable and never used it. This might be a bug with your code, so double-check what you have written. Otherwise, you might want to switch the variable name to _, or just prefix it with an underscore if you feel the name helps make the code readable.
./module.erl:5: Warning: a term is constructed, but never used
In one of your functions, you’re doing something such as building a list, or declaring a tuple or an anonymous function without ever binding it to a variable or returning it. This warning tells you that you’re doing something useless or have made some mistake.
./module.erl:5: head mismatch
It’s possible your function has more than one head, and each of them has a different arity. Don’t forget that different arity means different functions, and you can’t interleave function declarations that way.
Similarly, this error is raised when you insert a function definition between the head clauses of another function.
./module.erl:5: Warning: this clause cannot match because a previous clause at
line 4 always matches
A function defined in the module has a specific clause defined after a catchall one. As such, the compiler can warn you that you’ll never even need to go to the other branch.
./module.erl:9: variable 'A' unsafe in 'case' (line 5)
You’re using a variable declared within one of the branches of a case ... of outside of it. This is considered unsafe. If you want to use such variables, you’re better off doing MyVar = case ... of.