{"record":{"id":"a606bb321d14d09e","repo":"puppetlabs/puppet","slug":"expected-a-type-alias-assignment-on-the-form-alia","errorCode":null,"errorMessage":"Expected a type alias assignment on the form 'AliasType = T', got '%{assignment_string}'.\nCalled from <%{ruby_file_location}>","messagePattern":"Expected a type alias assignment on the form 'AliasType = T', got '%(.+?)'\\.\nCalled from <%(.+?)>","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/functions.rb","lineNumber":644,"sourceCode":"      # but strips off the rest of the internal \"where\" as it is not meaningful to user.\n      #\n      rb_location = caller(1, 1).first\n      begin\n        result = parser.parse_string(\"type #{assignment_string}\", nil)\n      rescue StandardError => e\n        rb_location = rb_location.gsub(/:in.*$/, '')\n        # Create a meaningful location for parse errors - show both what went wrong with the parsing\n        # and in which ruby file it was found.\n        raise ArgumentError, _(\"Parsing of 'type \\\"%{assignment_string}\\\"' failed with message: <%{message}>.\\n\" \\\n                               \"Called from <%{ruby_file_location}>\") % {\n                                 assignment_string: assignment_string,\n                                 message: e.message,\n                                 ruby_file_location: rb_location\n                               }\n      end\n      unless result.body.is_a?(Puppet::Pops::Model::TypeAlias)\n        rb_location = rb_location.gsub(/:in.*$/, '')\n        raise ArgumentError, _(\"Expected a type alias assignment on the form 'AliasType = T', got '%{assignment_string}'.\\n\" \\\n                               \"Called from <%{ruby_file_location}>\") % {\n                                 assignment_string: assignment_string,\n                                 ruby_file_location: rb_location\n                               }\n      end\n      @local_types << result.body\n    end\n  end\n\n  # @note WARNING: This style of creating functions is not public. It is a system\n  #   under development that will be used for creating \"system\" functions.\n  #\n  # This is a private, internal, system for creating functions. It supports\n  # everything that the public function definition system supports as well as a\n  # few extra features such as injection of well known parameters.\n  #\n  # @api private\n  class InternalFunction < Function","sourceCodeStart":626,"sourceCodeEnd":662,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/functions.rb#L626-L662","documentation":"After local_types parses a 'type ...' string successfully, the result body must be a Puppet::Pops::Model::TypeAlias node, that is, a real assignment 'AliasName = T'. A string that parses as something else (a bare expression, a function call) raises this ArgumentError with the Ruby location of the type call.","triggerScenarios":"local_types { type 'MyList' } (no '=' at all, parses as a bare type reference), or type 'MyList.size' style expressions. The parse succeeds but the body is not a TypeAlias.","commonSituations":"Forgetting the '=' in the alias assignment; writing a type expression where a definition was intended; shorthand habits from Puppet language manifests carried into the Ruby DSL.","solutions":["Write a full assignment: 'AliasName = Type', for example 'MyList = Array[String]'.","Check that exactly one '=' separates the new name from the existing type.","Reuse the standalone parser check to confirm the body class: result.body.is_a?(Puppet::Pops::Model::TypeAlias)."],"exampleFix":"# before: parses, but is not an alias assignment\n local_types { type 'MyList' }\n\n# after: correct 'AliasType = T' form\n local_types { type 'MyList = Array[String]' }","handlingStrategy":"validation","validationCode":"# Assert each alias string yields a real TypeAlias node\nresult = Puppet::Pops::Parser::Parser.new.parse_string('type MyList = Array[String]')\nraise 'not an alias assignment' unless result.body.is_a?(Puppet::Pops::Model::TypeAlias)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include the '=' between alias name and type.","Copy the 'AliasType = T' shape from working examples.","Add the TypeAlias assertion to CI checks over local type strings."],"tags":["puppet","functions","local-types","type-alias","dsl"],"backgroundTag":"invalid-type-alias","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}