Issue #16268 has been reported by Jochen Schalanda.

----------------------------------------
Bug #16268: Hash literals not allowed inside conditional block
https://projects.puppetlabs.com/issues/16268

Author: Jochen Schalanda
Status: Unreviewed
Priority: Normal
Assignee: 
Category: language
Target version: 
Affected Puppet version: 
Keywords: dsl
Branch: 


The Puppet DSL currently doesn’t allow hash literals expressions being used as 
the value in a conditional block. Using a temporary variable which holds the 
value works, though.

Non-working example:

    $test = undef ? {
      undef   => { 'test' => 'success' },
      default => 'foo',
    }
    notice($test)
    
Result with Puppet 2.7.19:

    $ puppet apply conditional_hash.pp 
    Could not parse for environment production: Syntax error at '{'; expected 
'}' at /tmp/conditional_hash.pp:2 on node localhost

Working example:

    $my_hash = { 'test' => 'success' }
    $test = undef ? {
      undef   => $my_hash,
      default => 'foo',
    }
    notice($test)

Result:

    $ puppet apply conditional_hash2.pp 
    notice: Scope(Class[main]): {"test"=>"success"}
    notice: Finished catalog run in 0.03 seconds


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" 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-bugs?hl=en.

Reply via email to