{"record":{"id":"38ec50ac54d8a90d","repo":"puppetlabs/puppet","slug":"creation-of-new-instance-of-type-type-is-not","errorCode":null,"errorMessage":"Creation of new instance of type '#{type}' is not supported","messagePattern":"Creation of new instance of type '#(.+?)' is not supported","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/pops/types/types.rb","lineNumber":345,"sourceCode":"  #\n  # @return [Function] the created function\n  # @raises ArgumentError\n  #\n  def new_function\n    self.class.new_function(self)\n  end\n\n  # This default implementation of of a new_function raises an Argument Error.\n  # Types for which creating a new instance is supported, should create and return\n  # a Puppet Function class by using Puppet:Loaders.create_loaded_function(:new, loader)\n  # and return that result.\n  #\n  # @param type [PAnyType] the type to create a new function for\n  # @return [Function] the created function\n  # @raises ArgumentError\n  #\n  def self.new_function(type)\n    raise ArgumentError, \"Creation of new instance of type '#{type}' is not supported\"\n  end\n\n  # Answers the question if instances of this type can represent themselves as a string that\n  # can then be passed to the create method\n  #\n  # @return [Boolean] whether or not the instance has a canonical string representation\n  def roundtrip_with_string?\n    false\n  end\n\n  # The default instance of this type. Each type in the type system has this constant\n  # declared.\n  #\n  DEFAULT = PAnyType.new\n\n  protected\n\n  # @api private","sourceCodeStart":327,"sourceCodeEnd":363,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/pops/types/types.rb#L327-L363","documentation":"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.","triggerScenarios":"Thrown at lib/puppet/pops/types/types.rb:345 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Call 'new' on a type that supports instantiation (e.g. String, Integer, Array)","Implement new_function on the custom type class to support creation","Construct instances directly in Ruby instead of via the new function"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","contentChangedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}