zf

zenflows testing
git clone https://s.sonu.ch/~srfsh/zf.git
Log | Files | Refs | Submodules | README | LICENSE

function_application_no_function.ex (1042B)


      1 defmodule Dialyxir.Warnings.FunctionApplicationNoFunction do
      2   @moduledoc """
      3   The function being invoked exists, but has an arity mismatch.
      4 
      5   ## Example
      6 
      7       defmodule Example do
      8         def ok() do
      9           fun = fn _ -> :ok end
     10           fun.()
     11         end
     12       end
     13   """
     14 
     15   @behaviour Dialyxir.Warning
     16 
     17   @impl Dialyxir.Warning
     18   @spec warning() :: :fun_app_no_fun
     19   def warning(), do: :fun_app_no_fun
     20 
     21   @impl Dialyxir.Warning
     22   @spec format_short([String.t()]) :: String.t()
     23   def format_short([_, _, arity]) do
     24     "Function application will fail, because anonymous function has arity of #{arity}."
     25   end
     26 
     27   @impl Dialyxir.Warning
     28   @spec format_long([String.t()]) :: String.t()
     29   def format_long([op, type, arity]) do
     30     pretty_op = Erlex.pretty_print(op)
     31     pretty_type = Erlex.pretty_print_type(type)
     32 
     33     "Function application will fail, because #{pretty_op} :: #{pretty_type} is not a function of arity #{arity}."
     34   end
     35 
     36   @impl Dialyxir.Warning
     37   @spec explain() :: String.t()
     38   def explain() do
     39     @moduledoc
     40   end
     41 end