Issue #6412 has been updated by Jacob Helwig.
Status changed from In Topic Branch Pending Review to Merged - Pending Release
Target version set to 2.7.10
This has been merged into 2.7.x in
commit:8ae917aaeabc47fe950e0d580adde2d28f373de7
(#6412) Return :undef when accessing non-existing hash/array elements
The truethiness test done in P::P::Scope.true? doesn't handle nil
values, because it is not valid as result of a puppet expression.
Unfortunately ruby hash['invalid'] or array[inexistant_index] returns
nil which then was considered as true in an if expression.
This patch makes sure :undef is returned in those cases.
----------------------------------------
Bug #6412: Can not test hash key exist?, or array element exist? in puppet
https://projects.puppetlabs.com/issues/6412
Author: Nan Liu
Status: Merged - Pending Release
Priority: Normal
Assignee:
Category: language
Target version: 2.7.10
Affected Puppet version: 2.6.4
Keywords:
Branch: https://github.com/puppetlabs/puppet/pull/211
The following tests fails in puppet for both array and hash:
$a=['1', '2', '3']
if $a[4] {
notice ("a[4] exists.")
}
$b={}
$b['bar'] = 'foo'
if $b['baz'] {
notice ("b['baz'] exists.")
}
The test is actually checking for the existence of variable $a, $b, testing
using == undef, == '' does not correct this behavior.
--
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.