diff options
Diffstat (limited to 'lib/puppet/parser')
-rw-r--r-- | lib/puppet/parser/ast/hostclass.rb | 7 | ||||
-rw-r--r-- | lib/puppet/parser/scope.rb | 13 |
2 files changed, 12 insertions, 8 deletions
diff --git a/lib/puppet/parser/ast/hostclass.rb b/lib/puppet/parser/ast/hostclass.rb index a5a228716..d6b323fb7 100644 --- a/lib/puppet/parser/ast/hostclass.rb +++ b/lib/puppet/parser/ast/hostclass.rb @@ -7,7 +7,10 @@ class Puppet::Parser::AST attr_accessor :parentclass def evaluate(scope,hash,objtype,objname) - if scope.lookupclass(@name) + # Verify that we haven't already been evaluated + # FIXME The second subclass won't evaluate the parent class + # code at all, and any overrides will throw an error. + if scope.lookupclass(self.object_id) Puppet.debug "%s class already evaluated" % @name return nil end @@ -26,7 +29,7 @@ class Puppet::Parser::AST # Set the mark after we evaluate, so we don't record it but # then encounter an error - scope.setclass(@name) + scope.setclass(self.object_id) return retval end diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb index 641a05758..3d1d690f5 100644 --- a/lib/puppet/parser/scope.rb +++ b/lib/puppet/parser/scope.rb @@ -530,13 +530,15 @@ module Puppet return Puppet::Parser::Scope.new(self) end - # Store the fact that we've evaluated a given class. - # FIXME Shouldn't setclass actually store the code, not just a boolean? - def setclass(klass) + # Store the fact that we've evaluated a given class. We use a hash + # that gets inherited from the nodescope down, rather than a global + # hash. We store the object ID, not class name, so that we + # can support multiple unrelated classes with the same name. + def setclass(id) if self.nodescope? or self.topscope? - @classtable[klass] = true + @classtable[id] = true else - @parent.setclass(klass) + @parent.setclass(id) end end @@ -578,7 +580,6 @@ module Puppet end # Return an interpolated string. - # FIXME We do not yet support a non-interpolated string. def strinterp(string) newstring = string.dup regex = Regexp.new('\$\{(\w+)\}|\$(\w+)') |