-
-
Notifications
You must be signed in to change notification settings - Fork 139
/
record_construction.ex
34 lines (28 loc) · 975 Bytes
/
record_construction.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
defmodule Dialyxir.Warnings.RecordConstruction do
@behaviour Dialyxir.Warning
@impl Dialyxir.Warning
@spec warning() :: :record_constr
def warning(), do: :record_constr
@impl Dialyxir.Warning
@spec explain() :: String.t()
def explain() do
Dialyxir.Warning.default_explain()
end
@impl Dialyxir.Warning
@spec format_short([String.t()]) :: String.t()
def format_short([_types, name]) do
"Record construction violates the declared type for #{name}."
end
def format_short([name, _field, _type]) do
"Record construction violates the declared type for #{name}."
end
@impl Dialyxir.Warning
@spec format_long([String.t()]) :: String.t()
def format_long([types, name]) do
"Record construction #{types} violates the declared type for ##{name}{}."
end
def format_long([name, field, type]) do
"Record construction violates the declared type for ##{name}{}, " <>
"because #{field} cannot be of type #{type}."
end
end