[erlang-questions] Type inference in Erlang [WAS: Re: The compiler "eats" structures which are not separated by commas]

Vlad Dumitrescu <>
Mon Apr 23 10:37:41 CEST 2012


On Mon, Apr 23, 2012 at 10:07, Ulf Wiger <> wrote:
> Obviously dialyzer is (extremely) useful, but there is a reason why it's off-line and doesn't actually give compilation errors, but merely advice.

So there is room for a simple and fast analysis of the code that would
catch some problems at compile time. Dialyzer is slow because it
infers the types, but if one would only consider the declared types
(as advice) and the type guards (as authoritative) and do local type
inference for a function clause at a time, then it should be fast
enough to have as a compiler phase.

One could argue that it's easy to see this kind of error without any
compiler help, after all there are huge systems in production that
work just fine. But since the compiler already warns for "hello + 1",
why shouldn't it warn for "X=hello, X+1" or "f(X) when is_atom(X) ->
X+1."?

best regards,
Vlad



More information about the erlang-questions mailing list