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

Regexp class parameter being understood as a String

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Cannot Reproduce
    • Affects Version/s: PUP 4.10.2
    • Fix Version/s: None
    • Component/s: Compiler, Language, Type System
    • Labels:
      None
    • Environment:

      $ puppet --version
      4.10.2

    • Template:
    • Sub-team:
    • Team:
      Server
    • Method Found:
      Needs Assessment
    • QA Risk Assessment:
      Needs Assessment

      Description

      When we pass a Regexp to a class, the class understands it as a String. To wit:

      {{class what (
        Regexp[/^.$/] $param,
      ) {
        notice('yes')
      }
       
      class { 'what':
        param => /^.$/,
      }
      

      $ puppet apply /tmp/z.pp 
      Error: Evaluation Error: Error while evaluating a Resource Statement, Class[Classname]: parameter 'param' expects a Regexp value, got String at /tmp/z.pp:7:1 on node cwl.hostopia.com}}
      
      

      https://pastebin.com/bHJ1vqub

       
      {{$regexp = /^.$/
      notice(type($regexp))
       
      class foo($bar) {
        notice(type($bar))
      }
       
      class { 'foo': bar => $regexp }
       
      Notice: Scope(Class[main]): Regexp[/^.$/]
      Notice: Scope(Class[Foo]): String}}
      

      https://gist.github.com/richardc/1380cda39d7bebca19ddc9dc06fb1a16

      Functions seem better though.

      # From <Volcane> 
      function x(Regexp $thing) { notice(type($thing)) }
      

      happily works.

        Attachments

          Activity

            jsd-sla-details-panel

              People

              • Assignee:
                Unassigned
                Reporter:
                cwood Christopher Wood
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: