diff options
| author | Paul Berry <paul@puppetlabs.com> | 2010-09-01 14:18:41 -0700 |
|---|---|---|
| committer | Paul Berry <paul@puppetlabs.com> | 2010-09-01 14:27:37 -0700 |
| commit | 25048ecc40db746f7e88bb6c5e1fc4f2c0150a4f (patch) | |
| tree | 11bda23eca92a698966695662c441c8b0066b70b /lib/puppet/parser/ast | |
| parent | fb9034731ddae41f1009745eb8eb1ea53aa05cfb (diff) | |
| download | puppet-25048ecc40db746f7e88bb6c5e1fc4f2c0150a4f.tar.gz puppet-25048ecc40db746f7e88bb6c5e1fc4f2c0150a4f.tar.xz puppet-25048ecc40db746f7e88bb6c5e1fc4f2c0150a4f.zip | |
[#4685] Classes, defines, and nodes allowed inside of non-evaluated conditionals
Previously, ASTArray#evaluate() was responsible for checking whether
the user had tried to declare a class, define, or node in a prohibited
location (such as a conditional construct). This meant that errors
would only be reported to the user if the conditional code was
actually evaluated.
Moved the checking into the parser, so that errors are always
reported.
Diffstat (limited to 'lib/puppet/parser/ast')
| -rw-r--r-- | lib/puppet/parser/ast/astarray.rb | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/lib/puppet/parser/ast/astarray.rb b/lib/puppet/parser/ast/astarray.rb index 432300c7a..e856570f8 100644 --- a/lib/puppet/parser/ast/astarray.rb +++ b/lib/puppet/parser/ast/astarray.rb @@ -9,11 +9,6 @@ class Puppet::Parser::AST class ASTArray < Branch include Enumerable - # True if this ASTArray represents a list of statements in a - # context that defines a namespace. Classes and definitions may - # only appear in such a context. - attr_accessor :is_a_namespace - # Return a child by index. Probably never used. def [](index) @children[index] @@ -37,17 +32,10 @@ class Puppet::Parser::AST } rets = items.flatten.collect { |child| - if child.respond_to? :instantiate - if is_a_namespace - # no problem, just don't evaluate it. - else - msg = "Classes, definitions, and nodes may only appear at toplevel or inside other classes" - error = Puppet::Error.new(msg) - error.line = child.line - error.file = child.file - raise error - end - else + # Skip things that respond to :instantiate (classes, nodes, + # and definitions), because they have already been + # instantiated. + if !child.respond_to?(:instantiate) child.safeevaluate(scope) end } |
