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

Parser validator should warn about duplicate keys in hash constructs

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PUP 4.5.0
    • Component/s: None
    • Labels:
      None
    • Template:
    • Epic Link:
    • Story Points:
      1
    • Sprint:
      Language 2016-03-09
    • Release Notes:
      New Feature
    • Release Notes Summary:
      With the new --strict flag in Puppet 4.5.0 you will now get warnings (or errors) when there is an attempt to set the same hash key more than once in the same hash.

      Description

      The keys in a hash construct are most often literals. As such, they can be validated during parsing so that the parser immediately complains about constructs like this:

      $myhash = {
        key       => "some value",
        other_key => "some other value",
        key       => "some overriding value"
      }
      notice( $myhash[key] )
      

      Presently, this is ignored and Puppet will notice 'some overriding value'. With a correct validation, it would instead issue a warning:

      The key 'key' is declared more than once at /some/path/to/a.pp:3:17
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                thomas.hallgren Thomas Hallgren
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Zendesk Support