-
-
Notifications
You must be signed in to change notification settings - Fork 139
/
exact_equality.ex
38 lines (30 loc) · 870 Bytes
/
exact_equality.ex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
defmodule Dialyxir.Warnings.ExactEquality do
@moduledoc """
The expression can never evaluate to true.
## Example
defmodule Example do
def ok() do
:ok == :error
end
end
"""
@behaviour Dialyxir.Warning
@impl Dialyxir.Warning
@spec warning() :: :exact_eq
def warning(), do: :exact_eq
@impl Dialyxir.Warning
@spec format_short([String.t()]) :: String.t()
def format_short(args), do: format_long(args)
@impl Dialyxir.Warning
@spec format_long([String.t()]) :: String.t()
def format_long([type1, op, type2]) do
pretty_type1 = Erlex.pretty_print_type(type1)
pretty_type2 = Erlex.pretty_print_type(type2)
"The test #{pretty_type1} #{op} #{pretty_type2} can never evaluate to 'true'."
end
@impl Dialyxir.Warning
@spec explain() :: String.t()
def explain() do
@moduledoc
end
end