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

4.x syntax error in '=>' in hash following another expression

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Won't Fix
    • Affects Version/s: PUP 4.0.0
    • Fix Version/s: None
    • Component/s: Language
    • Labels:
      None
    • Template:

      Description

      A user reported via IRC, and Richard Clamp repro'ed, the following issue using anonymous data structures to iterate over. The short version is that using an array, then a hash, confuses the parser, but hash then array works. So this is OK:

      class munin {
       
        {
          'if_eth0' => 'if_',
          'if_err_eth0' => 'if_err_',
        }.each |$plugin, $target| {
          notify { "hash ${plugin} ${target}": }
        }
       
        [
          'vmstat',
        ].each |$plugin| {
          notify { "array ${plugin}": }
        }
       
      }
      include munin
      

      but this is not:

      class munin {
        [
          'vmstat',
        ].each |$plugin| {
          notify { "array ${plugin}": }
        }
       
        {
          'if_eth0' => 'if_',
          'if_err_eth0' => 'if_err_',
        }.each |$plugin, $target| {
          notify { "hash ${plugin} ${target}": }
        }
      }
      include munin
      

      The error is:

      Error: Could not parse for environment production: Syntax error at '=>' at /home/vagrant/test.pp:8:15 on node glitched.local
      

        Attachments

          Activity

            jsd-sla-details-panel

              People

              • Assignee:
                Unassigned
                Reporter:
                eric.sorenson Eric Sorenson
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: