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

error message when using $name/$title variables could be more expressive

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Normal
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: PUP 4.1.0
    • Component/s: None
    • Labels:
      None
    • Template:
    • Epic Link:
    • Story Points:
      1
    • Sprint:
      Language 2015-04-29

      Description

      if one uses $name or $title as a define/class parameter you get a useful error that states that they are built in parameters:

      Error: The parameter $name redefines a built in parameter in the 'define' expression at /opt/puppet-git-repos/puppet/deftst.pp:2:3
      Error: The parameter $title redefines a built in parameter in the 'define' expression at /opt/puppet-git-repos/puppet/deftst.pp:3:3
      Error: The parameter $name redefines a built in parameter in the Host Class Definition at /opt/puppet-git-repos/puppet/deftst.pp:11:3
      Error: The parameter $title redefines a built in parameter in the Host Class Definition at /opt/puppet-git-repos/puppet/deftst.pp:12:3
      Error: Found 4 errors. Giving up
      Error: Found 4 errors. Giving up
      

      but if you try to use $name and $title otherwise it is a bit less useful and opaque to the user:

      [root@plgf5s85ojlj8m1 puppet]# puppet apply -e '$title = "lol" $name = "wut"'
      Error: Evaluation Error: Cannot reassign variable title  at line 1:8 on node plgf5s85ojlj8m1.delivery.puppetlabs.net
      Error: Evaluation Error: Cannot reassign variable title  at line 1:8 on node plgf5s85ojlj8m1.delivery.puppetlabs.net
      [root@plgf5s85ojlj8m1 puppet]# puppet apply -e 'define mydefinite ($title){}'
      Error: Could not parse for environment production: The parameter $title redefines a built in parameter in the 'define' expression  at line 1:20 on node plgf5s85ojlj8m1.delivery.puppetlabs.net
      Error: Could not parse for environment production: The parameter $title redefines a built in parameter in the 'define' expression  at line 1:20 on node plgf5s85ojlj8m1.delivery.puppetlabs.net
      [root@plgf5s85ojlj8m1 puppet]# puppet apply -e '[$title, $name] = ["lol","wut"]'
      Error: Evaluation Error: Cannot reassign variable title  at line 1:17 on node plgf5s85ojlj8m1.delivery.puppetlabs.net
      Error: Evaluation Error: Cannot reassign variable title  at line 1:17 on node plgf5s85ojlj8m1.delivery.puppetlabs.net
      [root@plgf5s85ojlj8m1 puppet]# puppet apply -e '[$name, $title] = ["lol","wut"]'
      Error: Evaluation Error: Cannot reassign variable name  at line 1:17 on node plgf5s85ojlj8m1.delivery.puppetlabs.net
      Error: Evaluation Error: Cannot reassign variable name  at line 1:17 on node plgf5s85ojlj8m1.delivery.puppetlabs.net
      

      risk: low
      probability: low
      severity: low
      test level: unit

        Attachments

          Issue Links

            Activity

              jsd-sla-details-panel

                People

                • Assignee:
                  Unassigned
                  Reporter:
                  erict Eric Thompson
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: