module Puppet::Pops::Evaluator::CallableMismatchDescriber

@api private

Public Class Methods

diff_string(name, args_type, supported_signatures) click to toggle source

Produces a string with the difference between the given arguments and support signature(s).

@param name [String] The name of the callable to describe @param args_type [Puppet::Pops::Types::Tuple] The tuple of argument types. @param supported_signatures [Array<Puppet::Pops::Types::Callable>] The available signatures that were available for calling.

@api private

# File lib/puppet/pops/evaluator/callable_mismatch_describer.rb, line 10
def self.diff_string(name, args_type, supported_signatures)
  result = [ ]
  if supported_signatures.size == 1
    signature = supported_signatures[0]
    params_type  = signature.type.param_types
    block_type   = signature.type.block_type
    params_names = signature.parameter_names
    result << "expected:\n  #{name}(#{signature_string(signature)}) - #{arg_count_string(signature.type)}"
  else
    result << "expected one of:\n"
    result << supported_signatures.map do |signature|
      params_type = signature.type.param_types
      "  #{name}(#{signature_string(signature)}) - #{arg_count_string(signature.type)}"
    end.join("\n")
  end

  result << "\nactual:\n  #{name}(#{arg_types_string(args_type)}) - #{arg_count_string(args_type)}"

  result.join('')
end