{"record":{"id":"3717857a2018a934","repo":"puppetlabs/puppet","slug":"member-attempts-to-override-label-without-ha","errorCode":null,"errorMessage":"%{member} attempts to override %{label} without having override => true","messagePattern":"%(.+?) attempts to override %(.+?) without having override => true","errorType":"exception","errorClass":"Puppet::ParseError","httpStatus":null,"severity":"error","filePath":"lib/puppet/pops/types/p_object_type.rb","lineNumber":181,"sourceCode":"      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\n\n    # @return [Boolean] `true` if this feature cannot be overridden\n    # @api public\n    def final?\n      @final\n    end\n","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/pops/types/p_object_type.rb#L163-L199","documentation":"Puppet requires overriding an inherited Object type member to be explicit: the child member must be declared with 'override' => true. assert_can_be_overridden raises this Puppet::ParseError when a same-named inherited member exists but the redeclaration does not carry the flag — protection against silently changing a parent contract by accident.","triggerScenarios":"Child Object type declares an attribute (or type parameter) with the same name as one inherited from its parent, without 'override' => true — e.g. parent has attribute 'name', child redeclares 'name' => String.","commonSituations":"Developers from mainstream OOP languages expecting implicit overriding; accidental name collisions with common attribute names ('name', 'id', 'version') that the parent already defines.","solutions":["If the redeclaration is intentional, add 'override' => true to the child member's hash.","If the name collision is accidental, rename the child's member.","Audit the parent type's attribute list when a child mysteriously fails to compile."],"exampleFix":"# before\ntype Sub = Object[{\n  'parent' => 'Base',\n  'attributes' => { 'size' => Integer }     # Base already defines 'size'\n}]\n\n# after\ntype Sub = Object[{\n  'parent' => 'Base',\n  'attributes' => { 'size' => {'type' => Integer, 'override' => true} }\n}]","handlingStrategy":"validation","validationCode":"# Ruby — when generating child types, set the flag automatically for redeclarations\nif parent_members.key?(name)\n  entry = entry.merge('override' => true)\nend","typeGuard":"def needs_override_flag?(name, parent_members)\n  parent_members.key?(name)\nend","tryCatchPattern":"begin\n  Puppet::Pops::Types::PObjectType.new(name, hash)\nrescue Puppet::ParseError => e\n  raise CompileError, \"redeclared inherited member without override => true: #{e.message}\"\nend","preventionTips":["When naming attributes, list the parent's members first and avoid collisions unless overriding deliberately.","Code-generate child types with an override flag inserted for every inherited name."],"tags":["puppet","object-type","inheritance","override","type-declaration"],"backgroundTag":"override-requires-keyword","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}