Dialyzer blames the code trying to match against module variable:
defmodule Main do
# -> :demo
@env Application.get_env(:myproject, :env)
def run do
case @env do
:production -> 1
_ -> 2
end
end
end
lib/myproject/main.ex:6:pattern_match
The pattern can never match the type.
Pattern:
:production
Type:
:demo
How can I avoid the warning, or should I write as below every time?
def run do
env = Application.get_env(:myproject, :env)
case env do
...
end
end