contract_range.ex (1191B)
1 defmodule Dialyxir.Warnings.ContractRange do 2 @behaviour Dialyxir.Warning 3 4 @impl Dialyxir.Warning 5 @spec warning() :: :contract_range 6 def warning(), do: :contract_range 7 8 @impl Dialyxir.Warning 9 @spec format_short([String.t()]) :: String.t() 10 def format_short([_, _, function | _]) do 11 "Contract cannot be correct because return type for #{function} is mismatched." 12 end 13 14 @impl Dialyxir.Warning 15 @spec format_long([String.t()]) :: String.t() 16 def format_long([contract, module, function, arg_strings, line, contract_return]) do 17 pretty_contract = Erlex.pretty_print_contract(contract) 18 pretty_module = Erlex.pretty_print(module) 19 pretty_contract_return = Erlex.pretty_print_type(contract_return) 20 pretty_args = Erlex.pretty_print_args(arg_strings) 21 22 """ 23 Contract cannot be correct because return type on line number #{line} is mismatched. 24 25 Function: 26 #{pretty_module}.#{function}#{pretty_args} 27 28 Type specification: 29 #{pretty_contract} 30 31 Success typing (line #{line}): 32 #{pretty_contract_return} 33 """ 34 end 35 36 @impl Dialyxir.Warning 37 @spec explain() :: String.t() 38 def explain() do 39 Dialyxir.Warning.default_explain() 40 end 41 end