I’m trying to understand how to make Dialyzer happy
If I following code
defmodule Test do
@flag1 false
def init() do
IO.puts "Execute always"
if @flag1 do
IO.puts "Execute in feature flag"
end
end
end
Dialyzer complains that
lib/test.ex:6: The pattern 'true' can never match the type 'false'
I had the impression that Elixir will not compile unreachable code to beam files.
But if does not, here is the disassembly:
-file("lib/test.ex", 1).
-module('Elixir.Test').
-compile(no_auto_import).
-export(['__info__'/1, init/0]).
-spec '__info__'(attributes | compile | exports |
functions | macros | md5 | module) -> atom() |
[{atom(), any()} |
{atom(), byte(),
integer()}].
'__info__'(functions) -> [{init, 0}];
'__info__'(macros) -> [];
'__info__'(info) ->
erlang:get_module_info('Elixir.Test', info).
init() ->
'Elixir.IO':puts(<<"Execute always">>),
case false of
false -> nil;
true -> 'Elixir.IO':puts(<<"Execute in feature flag">>)
end.
Any way to remove it somehow?