Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-7904

return() documentation incorrect regarding lambdas

    Details

    • Template:
    • Team:
      Platform Core
    • Method Found:
      Needs Assessment
    • Release Notes:
      Not Needed
    • QA Risk Assessment:
      Needs Assessment

      Description

      So the documentation for return() says plainly that it will return from a lambda, ending evaluation of the function.

      https://docs.puppet.com/puppet/4.10/function.html#return:

      If called from within a lambda the return will return from the function evaluating the lambda.

      So let's build a short manifest and use a function that evaluates a lambda:

      with(1) |$num| {
        return()
      }
      

      This creates an error:

      $ puppet apply return_bug.pp
      Error: return() from context where this is illegal at /tmp/return_bug.pp:2 on node 
      

      Reading the spec test confirms that this is expected behavior?
      https://github.com/puppetlabs/puppet/blob/ebd96213cab43bb2a8071b7ac0206c3ed0be8e58/spec/unit/functions/return_spec.rb#L85-L94

      I thought of perhaps creating this as a documentation bug, but this is failing on documented (and desirable) functionality.

        Attachments

          Activity

            People

            • Assignee:
              garrett.guillotte Garrett Guillotte
              Reporter:
              jorhett Jo Rhett
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Zendesk Support