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

Future parser error when interpolating name segment starting with underscore

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Done
    • Affects Version/s: PUP 3.7.4
    • Fix Version/s: PUP 3.7.5, PUP 4.0.0
    • Component/s: Compiler
    • Labels:
      None
    • Template:
    • Story Points:
      1
    • Sprint:
      Language 2015-03-18, Language 2015-04-01

      Description

      Variables starting with underscore are still supposed to be valid with the future parser, but interpolation of them doesn't work if they're accessed using their qualified variable name.

      eg

      $ cat leading_underscore.pp
      class bar ($foo) {
        $_foo = $foo
        notify {"Name of resource ${bar::_foo}":
          message => 'something witty here'
        }
      }
      class {'bar':
        foo => 'one',
      }
      $  puppet apply --parser=future leading_underscore.pp
      Error: Could not parse for environment production: Illegal fully qualified name in file /home/alex/github/test/leading_underscore.pp at line 3:36 on node alex-virtualbox.example.com
      Error: Could not parse for environment production: Illegal fully qualified name in file /home/alex/github/test/leading_underscore.pp at line 3:36 on node alex-virtualbox.example.com
      

      I discussed this on IRC and Richard Clamp came up with the following example that probably demonstrates the issue more clearly than mine.

      $ cat leading_underscore.pp
      class bar {
        $_foo = "one"
      }
       
      include bar
      notice("${bar::_foo}")
       
      $ puppet apply --parser=future leading_underscore.pp
      Error: Could not parse for environment production: Illegal fully qualified name in file /Users/richardc/src/leading_underscore.pp at line 10:18 on node socks.local
      Error: Could not parse for environment production: Illegal fully qualified name in file /Users/richardc/src/leading_underscore.pp at line 10:18 on node socks.local
       
      $ cat leading_underscoreworking.pp
      class bar {
        $_foo = "one"
      }
       
      include bar
      notice($bar::_foo)
       
      $ puppet apply --parser=future leading_underscoreworking.pp
      Notice: Scope(Class[main]): one
      Notice: Compiled catalog for socks.local in environment production in 0.51 seconds
      Notice: Finished catalog run in 0.03 seconds
      

      Thanks,
      Alex

      risk assessment: medium (FR only for now)
      probability: low (variables starting with underscores)
      severity: medium (work arounds exist)
      test layer: unit (https://github.com/puppetlabs/puppet/blob/dda2430457cd06c3381f02163dc9c15925b4bff7/spec/unit/pops/parser/lexer2_spec.rb#L230-L236)

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                alexjfisher Alexander Fisher
                QA Contact:
                Eric Thompson
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Zendesk Support