Fixing #477. setvar() can now accept the file and line info from callers.

git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2237 980ebf18-57e1-0310-9a29-db15c13687c0
This commit is contained in:
luke 2007-02-28 00:07:41 +00:00
Родитель d5444e0dd8
Коммит 07fce232e6
2 изменённых файлов: 10 добавлений и 3 удалений

Просмотреть файл

@ -15,7 +15,7 @@ class Puppet::Parser::AST
value = @value.safeevaluate(:scope => scope)
parsewrap do
scope.setvar(name,value)
scope.setvar(name,value, @file, @line)
end
end

Просмотреть файл

@ -519,12 +519,19 @@ class Puppet::Parser::Scope
# Set a variable in the current scope. This will override settings
# in scopes above, but will not allow variables in the current scope
# to be reassigned if we're declarative (which is the default).
def setvar(name,value)
def setvar(name,value, file = nil, line = nil)
#Puppet.debug "Setting %s to '%s' at level %s" %
# [name.inspect,value,self.level]
if @symtable.include?(name)
if @@declarative
raise Puppet::ParseError, "Cannot reassign variable %s" % name
error = Puppet::ParseError.new("Cannot reassign variable %s" % name)
if file
error.file = file
end
if line
error.line = line
end
raise error
else
Puppet.warning "Reassigning %s to %s" % [name,value]
end