Skip to content

Instantly share code, notes, and snippets.

@moxley
Created July 7, 2019 03:24
Show Gist options
  • Save moxley/992289a92378dc12978a10dff59fa120 to your computer and use it in GitHub Desktop.
Save moxley/992289a92378dc12978a10dff59fa120 to your computer and use it in GitHub Desktop.
Unexplainable Dialyzer warning
defmodule DialyzerTest do
def call(map) when is_map(map) do
with :ok <- validate_1(map[:value_1]),
:ok <- validate_2(map[:value_2]) do
:ok
else
{:error, reason} ->
# lib/dialyzer_test.ex:10:exact_eq
# The test :bad_value_2 == :bad_value_1 can never evaluate to 'true'.
if !map[:required] && reason == :bad_value_1 do
:ok
else
{:error, reason}
end
end
end
defp validate_1(true), do: :ok
defp validate_1(_), do: {:error, :bad_value_1}
defp validate_2(true), do: :ok
defp validate_2(_), do: {:error, :bad_value_2}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment