Issue #19812 has been updated by Charlie Sharpsteen.

Status changed from Unreviewed to Needs Decision
Assignee set to eric sorenson
Keywords changed from function api types to argument args types

There is a documentation clash here.

On one hand, our guide to writing [custom 
functions](http://docs.puppetlabs.com/guides/custom_functions.html#first-function-----small-steps)
 states that "there’s no real parameter validation, so you’ll need to do that 
yourself". Many custom functions explicitly typecast arguments because of this 
situation.

On the other hand, our [language 
reference](http://docs.puppetlabs.com/puppet/3/reference/lang_functions.html#arguments)
 claims that all arguments of numeric type will be converted to strings. As 
shown by this example, that conversion is not being enforced.

We can either change the docs to reflect that string/numeric conversion is 
ambiguous and therefore arguments should be validated inside functions before 
they are used, or change the compiler and risk breaking things that depend on 
the current behavior.

----------------------------------------
Bug #19812: The function API has "interesting" type conversions
https://projects.puppetlabs.com/issues/19812#change-87244

* Author: Erik Dalén
* Status: Needs Decision
* Priority: Normal
* Assignee: eric sorenson
* Category: functions
* Target version: 
* Affected Puppet version: 3.1.1
* Keywords: argument args types
* Branch: 
----------------------------------------
The type of parameters passed to functions is just weird:
foo(1) - String "1"
foo(1+1) - String "2"
foo($processorcount) - Numeric
foo(1*1) - Numeric 1
foo(1.0) - String "1.0"
foo(1.0+1) - Numeric 2.0
foo(1.0*1) - Numeric 1.0
foo("1"+"1") - String "2"
foo(undef) - String ""



-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-bugs?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to