From bba972fd1bcbb7747f73eee6b6789e02ad18071a Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 21 Aug 2006 23:50:51 +0000 Subject: Adding warnings and error throwing for #218 -- metaparams in prototypes are treated specially. git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1481 980ebf18-57e1-0310-9a29-db15c13687c0 --- lib/puppet/parser/ast/astarray.rb | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'lib/puppet/parser') diff --git a/lib/puppet/parser/ast/astarray.rb b/lib/puppet/parser/ast/astarray.rb index ab24fa86c..c42f658fd 100644 --- a/lib/puppet/parser/ast/astarray.rb +++ b/lib/puppet/parser/ast/astarray.rb @@ -111,5 +111,33 @@ class Puppet::Parser::AST # Another simple container class to make sure we can correctly arrayfy # things. - class CompArgument < ASTArray; end + class CompArgument < ASTArray + @@warnings = {} + def initialize(hash) + super + name = @children[0].value + + # If it's not a metaparamer, we're fine. + return unless Puppet::Type.metaparamclass(name) + + if @children[1] + if @children[1].value == false + raise Puppet::ParseError, + "%s is a metaparameter; please choose another name" % + name + else + unless @@warnings[name] + @@warnings[name] = true + Puppet.warning "%s is a metaparam; this value will inherit to all contained elements" % name + end + end + else + raise Puppet::ParseError, + "%s is a metaparameter; please choose another name" % + name + end + end + end end + +# $Id$ -- cgit