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

Empty Array type broken, neither Array[0,0] nor Array[T,0,0] works

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: PUP 4.4.2
    • Fix Version/s: PUP 4.4.3, PUP 4.5.0
    • Component/s: Language
    • Labels:
      None
    • Template:
    • Acceptance Criteria:
      Hide
      • That it is accepted to create a type like Array[Integer, 0,0] and that it will erase the type and present itself as Array[0,0]
      • That is is acceptable to create a type like Hash[K, V, 0, 0] and that it will erase the types and present itself as Hash[0,0]
      • That it is possible to create and use Array[0,0], and Hash[0,0] and that they match the corresponding empty structures.
      Show
      That it is accepted to create a type like Array [Integer, 0,0] and that it will erase the type and present itself as Array [0,0] That is is acceptable to create a type like Hash [K, V, 0, 0] and that it will erase the types and present itself as Hash [0,0] That it is possible to create and use Array [0,0] , and Hash [0,0] and that they match the corresponding empty structures.
    • Story Points:
      1
    • Sprint:
      Language 2016-05-04, Language 2016-05-18
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      Changes to the representation of empty Array and Hash led to problems in that it became impossible to state these types. Both Array[0,0], and Array[T, 0,0] resulted in errors.

      Description

      Since 4.4.2 it is impossible to do the following:

      if $nodes =~ Array[Data,0,0]
      

      I get the following error:

      Error while evaluating a '[]' expression, An empty collection may not specify an element type

      Non technical problems

      1. I would not expect such a change in a minor (.z) release
      2. This change does not make sense because it is a valid usecase (e.g when the upper limit is a variable) to have a type.

      Technical problems

      To me, the following statements are true

      [] =~ Array[String, 0, 0]
      [] =~ Array[Integer, 0, 0]
      

      Alternative writing does not work

      cat test.pp
      $test = assert_type(Array[0,0],[])
       
       
      puppet apply test.pp
      Error: Evaluation Error: Array-Type[] arguments must be types. Got Fixnum at /home/roidelapluie/test.pp:1:27 on node nitrogen
      

      So there is NO workaround to get the feature working again.

      Impossible to have a variable as length

      $test = assert_type(Array[Integer, $min,$max],[])
      

      will noly work with max > 0. Hence an extra if in the code etc etc

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                roidelapluie Julien Pivotto
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Zendesk Support