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

Aliased types are not indistinguishable from the original type

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: PUP 4.10.9, PUP 5.0.0
    • Fix Version/s: PUP 4.10.10, PUP 5.3.4, PUP 5.4.0
    • Component/s: Language
    • Labels:
      None
    • Template:
    • Sub-team:
    • Team:
      Platform Core
    • Story Points:
      1
    • Sprint:
      Platform Core KANBAN
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      A type alias to a type that is iterable did not allow the alias to be iterated. This is now fixed.
    • QA Risk Assessment:
      No Action

      Description

      I stumbled across a behavior relating to aliased data types which seems inconsistent with the documentation / specification. Per https://github.com/puppetlabs/puppet-specifications/blob/master/language/types_values_variables.md#type-aliases "An aliased type is indistinguishable from the original type." I believe I have found at least one instance where that is not so.

      Example 1:

      enum.pp

      $a = Enum['a','b']
      $a.each |$x| { notice($x) }
      

      $ puppet apply enum.pp 
      Notice: Scope(Class[main]): a
      Notice: Scope(Class[main]): b
      Notice: Compiled catalog for localhost.localdomain in environment production in 0.02 seconds
      Notice: Applied catalog in 0.09 seconds
      

      Example 2 (with aliased type):

      custom.pp

      type Custom = Enum['a','b']
      $a = Custom
      $a.each |$x| { notice($x) }
      

      $ puppet apply custom.pp 
      Error: Evaluation Error: Error while evaluating a Method call, 'each' expects one of:
        (Hash[Any, Any] hash, Callable[2, 2] block)
          rejected: parameter 'hash' expects a Hash value, got Type
        (Hash[Any, Any] hash, Callable[1, 1] block)
          rejected: parameter 'hash' expects a Hash value, got Type
        (Iterable enumerable, Callable[2, 2] block)
          rejected: parameter 'enumerable' expects an Iterable value, got Type
        (Iterable enumerable, Callable[1, 1] block)
          rejected: parameter 'enumerable' expects an Iterable value, got Type at custom.pp:4:3 on node localhost.localdomain
      

      I would have expected that the Iterable behavior would have transitioned with the custom type.

      I have seen this behavior on 4.7.0 as well as a current master branch (4.9.4-488-gcef0271).

      Thank you.

        Attachments

          Issue Links

            Activity

              jsd-sla-details-panel

                People

                • Assignee:
                  Unassigned
                  Reporter:
                  seanmil Sean Millichamp
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  5 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Zendesk Support