Details
Description
ORIGINAL REPORT
All the files are in .zip attached file. I have a (very basic) module with the function data.pp as data provider and the default value of a parameter is undef:
function test::data { |
{
|
test::foo::param => undef, |
}
|
}
|
In the class ::test::foo, I have this code:
class test::foo ( Optional[ String[1] ] $param ) { } |
As you can see, the type of the parameter $param is an Optional which means that a undef value is accepted. However, if I test this code:
include '::test::foo' |
I have an error:
~# puppet apply /puppet/modules/test/examples/example.pp
|
Error: Evaluation Error: Error while evaluating a Function Call, Class[Test::Foo]: expects a value for parameter 'param' at /puppet/modules/test/examples/example.pp:1:1 on node puppet.athome.priv
|
It seems to me that it's not the expected behavior.
Regards.
PS: currently a possible and simple workaround is to set a undef default value in the declaration of the class like this:
class test::foo ( Optional[ String[1] ] $param = undef ) { } |
but you have to set the undef value in two different places.
UPDATE
This is fixed so that if an undef value is bound for a parameter key data binding will assign that undef to the parameter if the parameter does not have a default value expression. Earlier such a binding would have failed and required that the parameter had a default value expression of = undef in order to make a lookup of undef possible.