From 9f30306d2c768bad3327ecb7748669afb10cd4aa Mon Sep 17 00:00:00 2001 From: Brice Figureau Date: Tue, 28 Oct 2008 14:15:08 +0100 Subject: Fix #857 - Multiple class of the same name don't append code The following manifest wasn't working: class one { notice('class one') } class one { notice('second class one') } include one It all boiled down to class code not being arrays. Encapsulating code in ASTArray when needed is enough to append code, because of the property of ASTArray to evaluate all their members in turn. Signed-off-by: Brice Figureau --- lib/puppet/parser/parser_support.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/puppet/parser') diff --git a/lib/puppet/parser/parser_support.rb b/lib/puppet/parser/parser_support.rb index 853d6aa86..1583973a7 100644 --- a/lib/puppet/parser/parser_support.rb +++ b/lib/puppet/parser/parser_support.rb @@ -291,10 +291,14 @@ class Puppet::Parser::Parser if tmp == "" tmp = "main" end - + Puppet.debug addcontext("Adding code to %s" % tmp) # Else, add our code to it. if other.code and code + # promote if neededcodes to ASTArray so that we can append code + # ASTArray knows how to evaluate its members. + other.code = ast AST::ASTArray, :children => [other.code] unless other.code.is_a?(AST::ASTArray) + code = ast AST::ASTArray, :children => [code] unless code.is_a?(AST::ASTArray) other.code.children += code.children else other.code ||= code -- cgit