puppetlabs/puppet · error · ArgumentError

Creation of new instance of type '#

Error message

Creation of new instance of type '#{type}' is not supported

What it means

PAnyType.new_function is a sentinel: this base implementation always raises because the type does not support instance creation via the 'new' function; only types that override new_function can be instantiated.

Solutions

  1. Call 'new' on a type that supports instantiation (e.g. String, Integer, Array)
  2. Implement new_function on the custom type class to support creation
  3. Construct instances directly in Ruby instead of via the new function
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at lib/puppet/pops/types/types.rb:345 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21). Data as JSON: /api/errors/38ec50ac54d8a90d. Report an issue: GitHub.

Appendix: source

Thrown at lib/puppet/pops/types/types.rb:345

  #
  # @return [Function] the created function
  # @raises ArgumentError
  #
  def new_function
    self.class.new_function(self)
  end

  # This default implementation of of a new_function raises an Argument Error.
  # Types for which creating a new instance is supported, should create and return
  # a Puppet Function class by using Puppet:Loaders.create_loaded_function(:new, loader)
  # and return that result.
  #
  # @param type [PAnyType] the type to create a new function for
  # @return [Function] the created function
  # @raises ArgumentError
  #
  def self.new_function(type)
    raise ArgumentError, "Creation of new instance of type '#{type}' is not supported"
  end

  # Answers the question if instances of this type can represent themselves as a string that
  # can then be passed to the create method
  #
  # @return [Boolean] whether or not the instance has a canonical string representation
  def roundtrip_with_string?
    false
  end

  # The default instance of this type. Each type in the type system has this constant
  # declared.
  #
  DEFAULT = PAnyType.new

  protected

  # @api private

View on GitHub (pinned to e227c27540)