From bacbe6ae382e627b03a724339ac674bf5c587ffa Mon Sep 17 00:00:00 2001 From: Thomas-Franklin Date: Thu, 25 Oct 2018 14:39:59 +0100 Subject: [PATCH] (PDK-1209) setting inherited const_defined lookup to false If there is a top level module with same name as a type which gets loaded before the type gets defined then this will trigger a false positive on the last_module.const_defined? check causing an `uninitialized constant` error. This change will no longer do a recursive check and only care about the local namespace this way avoiding the false positive. --- lib/puppet/resource_api.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet/resource_api.rb b/lib/puppet/resource_api.rb index 84e6d887..8c62d2d5 100644 --- a/lib/puppet/resource_api.rb +++ b/lib/puppet/resource_api.rb @@ -46,7 +46,7 @@ def register_type(definition) # this has to happen before Puppet::Type.newtype starts autoloading providers # it also needs to be guarded against the namespace already being defined by something # else to avoid ruby warnings - unless Puppet::Provider.const_defined?(class_name_from_type_name(definition[:name])) + unless Puppet::Provider.const_defined?(class_name_from_type_name(definition[:name]), false) Puppet::Provider.const_set(class_name_from_type_name(definition[:name]), Module.new) end