{"record":{"id":"7249217681e6daf1","repo":"puppetlabs/puppet","slug":"label-conflicts-with-attribute-with-the-same-na","errorCode":null,"errorMessage":"%{label} conflicts with attribute with the same name","messagePattern":"%(.+?) conflicts with attribute with the same name","errorType":"exception","errorClass":"Puppet::ParseError","httpStatus":null,"severity":"error","filePath":"lib/puppet/pops/types/p_object_type.rb","lineNumber":775,"sourceCode":"    unless attr_specs.empty?\n      @attributes = attr_specs.to_h do |key, attr_spec|\n        unless attr_spec.is_a?(Hash)\n          attr_type = TypeAsserter.assert_instance_of(nil, PTypeType::DEFAULT, attr_spec) { \"attribute #{label}[#{key}]\" }\n          attr_spec = { KEY_TYPE => attr_type }\n          attr_spec[KEY_VALUE] = nil if attr_type.is_a?(POptionalType)\n        end\n        attr = PAttribute.new(key, self, attr_spec)\n        [attr.name, attr.assert_override(parent_members)]\n      end.freeze\n    end\n\n    func_specs = init_hash[KEY_FUNCTIONS]\n    unless func_specs.nil? || func_specs.empty?\n      @functions = func_specs.to_h do |key, func_spec|\n        func_spec = { KEY_TYPE => TypeAsserter.assert_instance_of(nil, TYPE_FUNCTION_TYPE, func_spec) { \"function #{label}[#{key}]\" } } unless func_spec.is_a?(Hash)\n        func = PFunction.new(key, self, func_spec)\n        name = func.name\n        raise Puppet::ParseError, _(\"%{label} conflicts with attribute with the same name\") % { label: func.label } if @attributes.include?(name)\n\n        [name, func.assert_override(parent_members)]\n      end.freeze\n    end\n\n    @equality_include_type = init_hash[KEY_EQUALITY_INCLUDE_TYPE]\n    @equality_include_type = true if @equality_include_type.nil?\n\n    equality = init_hash[KEY_EQUALITY]\n    equality = [equality] if equality.is_a?(String)\n    if equality.is_a?(Array)\n      unless equality.empty?\n        # TRANSLATORS equality_include_type = false should not be translated\n        raise Puppet::ParseError, _('equality_include_type = false cannot be combined with non empty equality specification') unless @equality_include_type\n\n        parent_eq_attrs = nil\n        equality.each do |attr_name|\n          attr = parent_members[attr_name]","sourceCodeStart":757,"sourceCodeEnd":793,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/pops/types/p_object_type.rb#L757-L793","documentation":"An Object type may declare both attributes and functions, but they share one member namespace on the generated class. When a function is created whose name equals an already-declared attribute name, Puppet::ParseError is raised stating that the function label conflicts with an attribute of the same name.","triggerScenarios":"A type definition with functions => { size => Callable[[], String] } while size is also declared (or inherited onto this type's own attribute map) under attributes => { size => Integer }. The check runs during type resolution, before any instance exists.","commonSituations":"Adding a derived-value function whose name naturally collides with an attribute (size, name, version); renaming members on one side only; inheriting members from a parent and redefining the name as a function in the child.","solutions":["Rename either the function or the attribute so both names are unique within the type (e.g. size vs size_label)","If the function was meant to replace an inherited attribute's behavior, override the attribute instead of declaring a same-named function"],"exampleFix":"# before\ntype MyApp::T = Object[{\n  attributes => { size => Integer },\n  functions => { size => Callable[[], String] }\n}]\n\n# after\ntype MyApp::T = Object[{\n  attributes => { size => Integer },\n  functions => { size_label => Callable[[], String] }\n}]","handlingStrategy":"validation","validationCode":"# assert function names and attribute names are disjoint\noverlap = (func_specs.keys & attr_specs.keys)\nraise \"function/attribute name conflict: #{overlap.inspect}\" unless overlap.empty?","typeGuard":null,"tryCatchPattern":"begin\n  Puppet::Pops::Types::PObjectType.new(name, init_hash)\nrescue Puppet::ParseError => e\n  raise unless e.message =~ /conflicts with attribute with the same name/\n  raise  # e.message names the function; rename it or the attribute\nend","preventionTips":["Reserve a naming convention for derived functions (e.g. suffix _label, _computed) to avoid attribute collisions","When adding a function, check the type's attribute list (including inherited ones) first"],"tags":["puppet","pcore","object-type","name-conflict","schema"],"backgroundTag":"duplicate-member-name","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}