Issue #18234 has been updated by Henrik Lindberg. Description updated Category set to language Status changed from Unreviewed to Accepted Keywords changed from puppet hashes booleans defaults to puppet hashes booleans defaults evaluation
This is an evaluation error caused by the following line in puppet/parser/ast/leaf.rb (in class HashOrArrayAccess), line 154, which reads <pre> object[array_index_or_key(object, accesskey)] || :undef </pre> Which will change a literal false to :undef. I think this may be unintentional. Although, false, :undef, and '' are all not true, it is not quite the same thing as being literal false. ---------------------------------------- Bug #18234: Booleans used from within hashes not working correctly. https://projects.puppetlabs.com/issues/18234#change-79273 Author: Andrew Hendry Status: Accepted Priority: Normal Assignee: Category: language Target version: Affected Puppet version: Keywords: puppet hashes booleans defaults evaluation Branch: booleans_from_hashes.pp <pre>$puppet_hash = { hflag1 => true, hflag2 => false } notice("hflag1 should be true = '${puppet_hash[hflag1]}'") notice("hflag2 should be false = '${puppet_hash[hflag2]}'") dummy {'fromhash': flag1 => $puppet_hash[hflag1], flag2 => $puppet_hash[hflag2] } dummy {'assigned': flag1 => true, flag2 => false } define dummy ( $flag1 = true, $flag2 = true, ) { notice("${name} flag1 should be true = '${flag1}'") notice("${name} flag2 should be false = '${flag2}'") } </pre> Output: <pre> puppet apply booleans_from_hashes.pp notice: Scope(Class[main]): hflag1 should be true = 'true' notice: Scope(Class[main]): hflag2 should be false = '' notice: Scope(Dummy[fromhash]): fromhash flag1 should be true = 'true' notice: Scope(Dummy[fromhash]): fromhash flag2 should be false = 'true' notice: Scope(Dummy[assigned]): assigned flag1 should be true = 'true' notice: Scope(Dummy[assigned]): assigned flag2 should be false = 'false' notice: Finished catalog run in 0.04 seconds </pre> <pre> puppet --version 2.7.14 ruby --version ruby 1.8.7 (2010-06-23 patchlevel 299) [x86_64-linux] </pre> flag2 should be false when pulled from the hash but it appears to be empty, resulting in the default being used. This does not happen when passing booleans directly. Does anyone know a workaround or fix? -- 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.
