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

Add migration check for type mismatch in equality test

    XMLWordPrintable

Details

    • New Feature
    • Status: Closed
    • Normal
    • Resolution: Done
    • None
    • PUP 3.8.0, PUP 4.1.0
    • None
    • None

    Description

      In 4.0, comparison of String and Number is different.

      '1' == 1 # 4x. false, 3x. true
      '1' <= 1 # 4x. error, 3x. true

      Since 4.0 errors on comparison but not on equality, the equality operators must check their arguments. If a String and a Number are checked for equality this should result in a diagnostic for the operator.

      Add MIGRATE4_EQUALITY_TYPE_MISMATCH to to MigrationIssues with the text:

      "#{the(semantic)} always evaluates to false due to type mismatch #{left.class} #{right.class} (3.x. may evaluate to true)"
      

      Add a report_equality_type_mismatch(left_value, right_value, o) where the semantic o is the equality expression to the MigrationChecker, and report if left/right have mismatch on String/Number.

      Call this report method from the equality and comparison operator evaluation methods.

      (Add method stubs to the MigrationChecker in the puppet repository and the concrete methods to the implementation in the module created in PUP-4149).

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              henrik.lindberg Henrik Lindberg
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Zendesk Support