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

Puppet types sometimes fail to compare for equality

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PUP 4.4.0
    • Component/s: None
    • Labels:
      None
    • Template:
    • Story Points:
      1
    • Sprint:
      Language 2016-03-09, Language 2016-03-23
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      Hide
      A problem was found with the == operator when directly comparing one data type against another. The =~ operator was unaffected. This bug could cause undefined behavior for types used as keys in hashes, and could result in output of wrong type as the expected type in a type mismatch error.
      Show
      A problem was found with the == operator when directly comparing one data type against another. The =~ operator was unaffected. This bug could cause undefined behavior for types used as keys in hashes, and could result in output of wrong type as the expected type in a type mismatch error.

      Description

      The Puppet type system uses a == method in the topmost PAnyType class and then other types adds overrides for that method. The topmost class also declares eql? as an alias for ==. This doesn't work because the alias does not recognize the overrides. It still points to the method in the topmost class.

      As a consequence, when comparing types for equality using the eql? method, only the topmost == method was used. The eql? method is used by Hash, Set and method like Ruby uniq.

      The bug can be observed using puppet apply:

      puppet apply -e "notice({ Variant[Enum[a,b,c]] => 'first', Variant[Pattern[a,b,c]] => 'second'})"
      Notice: Scope(Class[main]): {Variant[Enum['a', 'b', 'c']] => second}
      

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved:

                  Zendesk Support