diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-06-01 00:48:56 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-06-01 00:48:56 +0000 |
| commit | add6b805e84feb2636335b1b3a87ef1b11db60a5 (patch) | |
| tree | c83c672ba2aebf8f2f0a24c6e27fc7d36a7df584 /lib/puppet | |
| parent | 76ff83d86ce2bfaea69bb57af766833ea21095a5 (diff) | |
| download | puppet-add6b805e84feb2636335b1b3a87ef1b11db60a5.tar.gz puppet-add6b805e84feb2636335b1b3a87ef1b11db60a5.tar.xz puppet-add6b805e84feb2636335b1b3a87ef1b11db60a5.zip | |
Fixing #160. Fixing the error in Puppet::Type#[]= and scope.newobject
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1230 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet')
| -rw-r--r-- | lib/puppet/parser/scope.rb | 16 | ||||
| -rw-r--r-- | lib/puppet/type.rb | 19 |
2 files changed, 24 insertions, 11 deletions
diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb index e0afbae4a..89cd42022 100644 --- a/lib/puppet/parser/scope.rb +++ b/lib/puppet/parser/scope.rb @@ -94,17 +94,23 @@ module Puppet::Parser if typeklass and ! typeklass.isomorphic? Puppet.info "Allowing duplicate %s" % type else + exobj = @definedtable[type][name] + # Either it's a defined type, which are never # isomorphic, or it's a non-isomorphic type. msg = "Duplicate definition: %s[%s] is already defined" % [type, name] - error = Puppet::ParseError.new(msg) - if hash[:line] - error.line = hash[:line] + + if exobj.file and exobj.line + msg << " in file %s at line %s" % + [exobj.file, exobj.line] end - if hash[:file] - error.file = hash[:file] + + if hash[:line] or hash[:file] + msg << "; cannot redefine" end + + error = Puppet::ParseError.new(msg) raise error end end diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index 95691aaee..16ffac085 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -260,12 +260,19 @@ class Type < Puppet::Element raise Puppet::DevError, "must pass a Puppet::Type object" end - if @objects.has_key?(name) and self.isomorphic? - raise Puppet::Error.new( - "Object '%s' of type '%s' already exists with id '%s' vs. '%s'" % - [name, newobj.class.name, - @objects[name].object_id,newobj.object_id] - ) + if exobj = @objects.has_key?(name) and self.isomorphic? + msg = "Object '%s[%s]' already exists" % + [name, newobj.class.name] + + if exobj.file and exobj.line + msg += ("in file %s at line %s" % + [object.file, object.line]) + end + if object.file and object.line + msg += ("and cannot be redefined in file %s at line %s" % + [object.file, object.line]) + end + error = Puppet::Error.new(msg) else #Puppet.info("adding %s of type %s to class list" % # [name,object.class]) |
