diff options
| author | Markus Roberts <Markus@reality.com> | 2010-10-24 23:29:38 -0700 |
|---|---|---|
| committer | Nick Lewis <nick@puppetlabs.com> | 2011-04-12 12:47:32 -0700 |
| commit | 739260b28d7c09bacbb34cd4f4d4a32cfee01385 (patch) | |
| tree | 9dc514930f0f433786211a9c8c07742aec99ae01 /lib/puppet/parser/ast | |
| parent | d7201ed38929f867d31bc9b916e90679606dc9f8 (diff) | |
| download | puppet-739260b28d7c09bacbb34cd4f4d4a32cfee01385.tar.gz puppet-739260b28d7c09bacbb34cd4f4d4a32cfee01385.tar.xz puppet-739260b28d7c09bacbb34cd4f4d4a32cfee01385.zip | |
Towards 5027 -- add options hash to lookupvar as with setvar
This patch adds an options hash to lookupvar analogous to the one taken by
setvar and uses it to pass in source location for error reporting. It also
fixes the mechanism used by setvar (file was not being passed correctly), adds
line and file information to errors in templates, and extends/corrects tests.
As presently written it does not gather userful line numbers from inline
templates and there are no tests for the template line number generation.
Diffstat (limited to 'lib/puppet/parser/ast')
| -rw-r--r-- | lib/puppet/parser/ast/leaf.rb | 4 | ||||
| -rw-r--r-- | lib/puppet/parser/ast/vardef.rb | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/puppet/parser/ast/leaf.rb b/lib/puppet/parser/ast/leaf.rb index b61634d6c..c8ebc9483 100644 --- a/lib/puppet/parser/ast/leaf.rb +++ b/lib/puppet/parser/ast/leaf.rb @@ -124,7 +124,7 @@ class Puppet::Parser::AST # not include syntactical constructs, like '$' and '{}'). def evaluate(scope) parsewrap do - if (var = scope.lookupvar(@value)) == :undefined + if (var = scope.lookupvar(@value, :file => file, :line => line)) == :undefined var = :undef end var @@ -141,7 +141,7 @@ class Puppet::Parser::AST def evaluate_container(scope) container = variable.respond_to?(:evaluate) ? variable.safeevaluate(scope) : variable - (container.is_a?(Hash) or container.is_a?(Array)) ? container : scope.lookupvar(container) + (container.is_a?(Hash) or container.is_a?(Array)) ? container : scope.lookupvar(container, :file => file, :line => line) end def evaluate_key(scope) diff --git a/lib/puppet/parser/ast/vardef.rb b/lib/puppet/parser/ast/vardef.rb index 6de1860c8..b766311dd 100644 --- a/lib/puppet/parser/ast/vardef.rb +++ b/lib/puppet/parser/ast/vardef.rb @@ -20,7 +20,7 @@ class Puppet::Parser::AST name = @name.safeevaluate(scope) parsewrap do - scope.setvar(name,value, :file => @file, :line => @line, :append => @append) + scope.setvar(name,value, :file => file, :line => line, :append => @append) end end end |
