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

Validator incorrectly reports result of regexp match as being forgotten

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Normal
    • Resolution: Fixed
    • None
    • PUP 5.5.0
    • None
    • Platform Core
    • Platform Core KANBAN
    • Needs Assessment
    • Bug Fix
    • Hide
      A sequence such as:
      {code:puppet}
      'cdf' =~ /^([a-z])(.*)/
      notice($2)
      {code}
      Would result in an error that the match expression had no effect. This was caused by validation not considering that numeric match variables may be set as a side-effect of evaluating the match. This is not corrected.
      Show
      A sequence such as: {code:puppet} 'cdf' =~ /^([a-z])(.*)/ notice($2) {code} Would result in an error that the match expression had no effect. This was caused by validation not considering that numeric match variables may be set as a side-effect of evaluating the match. This is not corrected.
    • Needs Assessment

    Description

      The following manifest errors when evaluated using puppet apply:

      'cdf' =~ /^([a-z])(.*)/
      notice($2)
      

      The error is:

      This '=~' expression has no effect. A value was produced and then forgotten (one or more preceding expressions may have the wrong form)
      

      This is not correct since the result of the match is stored in numeric variables $1 ... $n and can be used.

      Turning the comparison into an assignment, i.e.:

      $x = 'cdf' =~ /^([a-z])(.*)/
      notice($2)
      

      yields the correct result:

      Notice: Scope(Class[main]): df
      

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Zendesk Support