zf

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

function_application_arguments.ex (1744B)


      1 defmodule Dialyxir.Warnings.FunctionApplicationArguments do
      2   @behaviour Dialyxir.Warning
      3 
      4   @impl Dialyxir.Warning
      5   @spec warning() :: :fun_app_args
      6   def warning(), do: :fun_app_args
      7 
      8   @impl Dialyxir.Warning
      9   @spec format_short([String.t()]) :: String.t()
     10   def format_short([args, _type]) do
     11     pretty_args = Erlex.pretty_print_args(args)
     12     "Function application with #{pretty_args} will fail."
     13   end
     14 
     15   # OTP 22+ format
     16   def format_short([_arg_positions, args, type]) do
     17     format_short([args, type])
     18   end
     19 
     20   @impl Dialyxir.Warning
     21   @spec format_long([String.t()]) :: String.t()
     22   def format_long([args, type]) do
     23     pretty_args = Erlex.pretty_print_args(args)
     24     pretty_type = Erlex.pretty_print(type)
     25 
     26     "Function application with arguments #{pretty_args} will fail, " <>
     27       "because the function has type #{pretty_type}."
     28   end
     29 
     30   # OTP 22+ format
     31   def format_long([arg_positions, args, type]) do
     32     pretty_arg_positions = form_positions(arg_positions)
     33     pretty_args = Erlex.pretty_print_args(args)
     34     pretty_type = Erlex.pretty_print(type)
     35 
     36     "Function application with arguments #{pretty_args} will fail, " <>
     37       "because the function has type #{pretty_type}, " <>
     38       "which differs in #{pretty_arg_positions}."
     39   end
     40 
     41   defp form_positions(arg_positions = [_]) do
     42     form_position_string = Dialyxir.WarningHelpers.form_position_string(arg_positions)
     43     "the #{form_position_string} argument"
     44   end
     45 
     46   defp form_positions(arg_positions) do
     47     form_position_string = Dialyxir.WarningHelpers.form_position_string(arg_positions)
     48     "the #{form_position_string} arguments"
     49   end
     50 
     51   @impl Dialyxir.Warning
     52   @spec explain() :: String.t()
     53   def explain() do
     54     Dialyxir.Warning.default_explain()
     55   end
     56 end