The following manifest was producing a parse error:
$int = { 'eth0' => 'bla' }
$foo = $int['eth0'] ? {
  'bla' => 'foo',
   default => 'bleh'
}

because selectors didn't support hash access.

Signed-off-by: Brice Figureau <[email protected]>
---
 lib/puppet/parser/grammar.ra    |    1 +
 lib/puppet/parser/parser.rb     |  841 +++++++++++++++++++--------------------
 spec/unit/parser/parser_spec.rb |    6 +
 3 files changed, 422 insertions(+), 426 deletions(-)

diff --git a/lib/puppet/parser/grammar.ra b/lib/puppet/parser/grammar.ra
index 7a316d4..3a386d8 100644
--- a/lib/puppet/parser/grammar.ra
+++ b/lib/puppet/parser/grammar.ra
@@ -642,6 +642,7 @@ selectlhand:  name
   | funcrvalue
   | boolean
   | undef
+  | hasharrayaccess
   | DEFAULT {
     result = ast AST::Default, :value => val[0][:value], :line => val[0][:line]
 }
[elided autogenerated parser.rb]
diff --git a/spec/unit/parser/parser_spec.rb b/spec/unit/parser/parser_spec.rb
index 07e2d22..9e4c795 100755
--- a/spec/unit/parser/parser_spec.rb
+++ b/spec/unit/parser/parser_spec.rb
@@ -76,6 +76,12 @@ describe Puppet::Parser do
 
   end
 
+  describe "when parsing selector" do
+    it "should support hash access on the left hand side" do
+      lambda { @parser.parse("$h = { 'a' => 'b' } $a = $h['a'] ? { 'b' => 'd', 
default => undef }") }.should_not raise_error
+    end
+  end
+
   describe "when parsing 'if'" do
     it "not, it should create the correct ast objects" do
       ast::Not.expects(:new).with { |h| h[:value].is_a?(ast::Boolean) }
-- 
1.7.2.1

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to