You are confusing upcoming Elixir gradual-type system and JIT type tracking where Erlang is able to omit some guards for private functions when it can guarantee that it will be called only with values that do not require type check. For example if you do:
defmodule Foo do
def foo(a, b) when is_integer(a) and is_integer(b), do: a + bar(b)
def bar(b) when is_integer(b), do: b + 1
end
Compiler need to keep guards in both functions, as it do not know if bar/1 will be called only with integer. However if we write it as:
defmodule Foo do
def foo(a, b) when is_integer(a) and is_integer(b), do: a + bar(b)
defp bar(b) when is_integer(b), do: b + 1
end
Then it can “deduce” that bar/1 is called only with integer (as it is private, and the only caller already checks if that is integer or not). So it can optimise second guard away, as it has guarantee that it is integer.






















