{"record":{"id":"48fce179adefadbc","repo":"puppetlabs/puppet","slug":"member-attempts-to-override-label","errorCode":null,"errorMessage":"%{member} attempts to override %{label}","messagePattern":"%(.+?) attempts to override %(.+?)","errorType":"exception","errorClass":"Puppet::ParseError","httpStatus":null,"severity":"error","filePath":"lib/puppet/pops/types/p_object_type.rb","lineNumber":174,"sourceCode":"        if @override\n          raise Puppet::ParseError, _(\"expected %{label} to override an inherited %{feature_type}, but no such %{feature_type} was found\") %\n                                    { label: label, feature_type: feature_type }\n        end\n        self\n      else\n        parent_member.assert_can_be_overridden(self)\n      end\n    end\n\n    # Checks if the given _member_ can override this member.\n    #\n    # @param member [PAnnotatedMember] the overriding member\n    # @return [PAnnotatedMember] its argument\n    # @raises [Puppet::ParseError] if the assertion fails\n    # @api private\n    def assert_can_be_overridden(member)\n      unless instance_of?(member.class)\n        raise Puppet::ParseError, _(\"%{member} attempts to override %{label}\") % { member: member.label, label: label }\n      end\n      if @final && !(constant? && member.constant?)\n        raise Puppet::ParseError, _(\"%{member} attempts to override final %{label}\") % { member: member.label, label: label }\n      end\n      unless member.override?\n        # TRANSLATOR 'override => true' is a puppet syntax and should not be translated\n        raise Puppet::ParseError, _(\"%{member} attempts to override %{label} without having override => true\") % { member: member.label, label: label }\n      end\n      unless @type.assignable?(member.type)\n        raise Puppet::ParseError, _(\"%{member} attempts to override %{label} with a type that does not match\") % { member: member.label, label: label }\n      end\n\n      member\n    end\n\n    def constant?\n      false\n    end","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/pops/types/p_object_type.rb#L156-L192","documentation":"An overriding member must be the same kind of feature as the inherited member it replaces: an attribute overrides an attribute, a type parameter overrides a type parameter. assert_can_be_overridden checks instance_of?(member.class); a mismatch (attribute vs PTypeParameter) raises this Puppet::ParseError.","triggerScenarios":"A child Object type defines an entry under 'attributes' with the same name as the parent's entry under 'type_parameters' (or vice versa), with override => true — the kinds differ, so the override is rejected.","commonSituations":"Promoting a parent's type parameter to a real attribute (or the reverse) in a subtype; hand-editing generated type hashes and moving entries between the two sections without renaming.","solutions":["Keep the member in the same section as the parent: override the type parameter under 'type_parameters', or the attribute under 'attributes'.","If the kind genuinely must change, use a new member name instead of overriding.","Remove 'override' => true if you did not intend an override at all."],"exampleFix":"# before — parent declares 'size' as a type_parameter, child re-declares it as an attribute\ntype Sub = Object[{'parent' => 'Base', 'attributes' => {'size' => {'type' => Integer, 'override' => true}}}]\n\n# after — override it in the matching section\ntype Sub = Object[{'parent' => 'Base', 'type_parameters' => {'size' => {'type' => Integer, 'override' => true}}}]","handlingStrategy":"validation","validationCode":"# Ruby — when building child types, keep members in the parent's section\n(parent.type_parameters.key?(name) ? child_type_params : child_attributes)[name] = entry","typeGuard":"def same_member_kind?(parent_member, child_member)\n  parent_member.instance_of?(child_member.class)\nend","tryCatchPattern":"begin\n  child_type = Puppet::Pops::Types::PObjectType.new(child_name, child_hash)\nrescue Puppet::ParseError => e\n  raise CompileError, \"kind mismatch in override: #{e.message}\"\nend","preventionTips":["Never move a member between 'attributes' and 'type_parameters' in a subtype without renaming it.","Keep a convention: type parameters describe parameterization, attributes describe instance data."],"tags":["puppet","object-type","inheritance","override","type-declaration"],"backgroundTag":"member-kind-mismatch-override","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}