summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/ast
diff options
context:
space:
mode:
authorLuke Kanies <luke@puppetlabs.com>2011-07-05 16:32:03 -0700
committerLuke Kanies <luke@puppetlabs.com>2011-07-15 11:52:41 -0700
commitbdc0f8716ae8ccb2b2657dfab591afe9589d8902 (patch)
tree6f6b25251f0a581c878b833a90e5b3bab0ac5d11 /lib/puppet/parser/ast
parent9662045bfe551821823b38fe6511e621998aef0b (diff)
downloadpuppet-bdc0f8716ae8ccb2b2657dfab591afe9589d8902.tar.gz
puppet-bdc0f8716ae8ccb2b2657dfab591afe9589d8902.tar.xz
puppet-bdc0f8716ae8ccb2b2657dfab591afe9589d8902.zip
Scope[] now returns nil for undefined variables
Given that we have the 'include?' method, this feature is unnecessary, and it makes sense to convert to more ruby-like behavior. Any code that previously checked whether lookupvar (or the new []) returned :undefined should now check whether 'scope.include?(var)'. Thus, you can have the same behavior, but it takes a bit different code to get it. Signed-off-by: Luke Kanies <luke@puppetlabs.com> Reviewed-by: Nick Lewis <nick@puppetlabs.com>
Diffstat (limited to 'lib/puppet/parser/ast')
-rw-r--r--lib/puppet/parser/ast/leaf.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/puppet/parser/ast/leaf.rb b/lib/puppet/parser/ast/leaf.rb
index 64a197492..3efb52f63 100644
--- a/lib/puppet/parser/ast/leaf.rb
+++ b/lib/puppet/parser/ast/leaf.rb
@@ -124,10 +124,11 @@ class Puppet::Parser::AST
# not include syntactical constructs, like '$' and '{}').
def evaluate(scope)
parsewrap do
- if (var = scope[@value, {:file => file, :line => line}]) == :undefined
- var = :undef
+ if ! scope.include?(@value)
+ :undef
+ else
+ scope[@value, {:file => file, :line => line}]
end
- var
end
end