diff options
-rw-r--r-- | lib/puppet/parser/scope.rb | 8 | ||||
-rwxr-xr-x | test/language/scope.rb | 20 |
2 files changed, 26 insertions, 2 deletions
diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb index e81664219..b441fd4bc 100644 --- a/lib/puppet/parser/scope.rb +++ b/lib/puppet/parser/scope.rb @@ -639,7 +639,13 @@ module Puppet # Define our type. def settype(name,ltype) - @typetable[name] = ltype + # Don't let them redefine the class in this scope. + if @typetable.include?(name) + raise Puppet::ParseError, + "%s is already defined" % name + else + @typetable[name] = ltype + end end # Return an interpolated string. diff --git a/test/language/scope.rb b/test/language/scope.rb index b4a546267..ee896ab32 100755 --- a/test/language/scope.rb +++ b/test/language/scope.rb @@ -411,7 +411,25 @@ class TestScope < Test::Unit::TestCase assert_equal("bin", file["owner"], "Value did not override correctly") } end + + def test_multipletypes + scope = Puppet::Parser::Scope.new() + children = [] - def test_classscopes + # create the parent class + children << classobj("aclass") + children << classobj("aclass") + top = nil + assert_nothing_raised("Could not create top object") { + top = AST::ASTArray.new( + :children => children + ) + } + + scope = nil + assert_raise(Puppet::ParseError) { + scope = Puppet::Parser::Scope.new() + objects = top.evaluate(:scope => scope) + } end end |