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

Data types seems to be messed up on hash parameters

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • PUP 4.3.2
    • PUP 3.8.7, PUP 4.4.0
    • Language
    • None
    • Bug Fix
    • Our old foe :undef turned up again due to 3.x calling convention also applying to resource expressions.

    Description

      The following code:

      define test ($b) {
        $a = { key => undef }
        notice("a: $a")
        notice("b: $b")
        $a.each |Array $values| {
          notice("a values: $values")
        }
        $b.each |Array $values| {
          notice("b values: $values")
        }
      }
       
      $a = { key => undef }
      test { "test":
        b => $a,
      }
      

      generates the following output if run with puppet apply:

      puppet apply test.pp
      Notice: Scope(Test[test]): a: {key => }
      Notice: Scope(Test[test]): b: {key => }
      Notice: Scope(Test[test]): a values: [key, ]
      Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Method call, block parameter 'values' expects an Array value, got Tuple at /home/rvicinus/test.pp:8:5  at /home/rvicinus/test.pp:14 on node puppetmaster
      

      I would expect that the second each statement would run like the first, because the supplied hash is absolutely equally created like the one provided to the first each statement. I think somehow assigning the hash to a parameter messes up the data types, because the code works as expected if the Array keyword in the second each statement is removed. This is also the workaround that I use.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              vicinus Reinhard Vicinus
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Zendesk Support