zf

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

apply.ex (1232B)


      1 defmodule Dialyxir.Warnings.Apply do
      2   @moduledoc """
      3   The function being invoked exists, and has the correct arity, but
      4   will not succeed.
      5 
      6   ## Example
      7 
      8       defmodule Example do
      9         def ok() do
     10           fun = fn :ok -> :ok end
     11           fun.(:error)
     12         end
     13       end
     14   """
     15 
     16   @behaviour Dialyxir.Warning
     17 
     18   @impl Dialyxir.Warning
     19   @spec warning() :: :apply
     20   def warning(), do: :apply
     21 
     22   @impl Dialyxir.Warning
     23   @spec format_short([String.t()]) :: String.t()
     24   def format_short([args | _]) do
     25     pretty_args = Erlex.pretty_print_args(args)
     26     "Function application with args #{pretty_args} will not succeed."
     27   end
     28 
     29   @impl Dialyxir.Warning
     30   @spec format_long([String.t()]) :: String.t()
     31   def format_long([args, arg_positions, fail_reason, signature_args, signature_return, contract]) do
     32     pretty_args = Erlex.pretty_print_args(args)
     33 
     34     call_string =
     35       Dialyxir.WarningHelpers.call_or_apply_to_string(
     36         arg_positions,
     37         fail_reason,
     38         signature_args,
     39         signature_return,
     40         contract
     41       )
     42 
     43     "Function application with arguments #{pretty_args} #{call_string}"
     44   end
     45 
     46   @impl Dialyxir.Warning
     47   @spec explain() :: String.t()
     48   def explain() do
     49     @moduledoc
     50   end
     51 end