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

Future parser returns nil when parsing a source that contains no statements

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: PUP 3.6.1
    • Fix Version/s: PUP 3.7.0
    • Component/s: Compiler
    • Labels:
    • Template:
    • Story Points:
      1
    • Sprint:
      2014-07-23

      Description

      Consider the following example:

      require 'puppet'
      require 'puppet/pops'
       
      parser = Puppet::Pops::Parser::Parser.new
       
      result = parser.parse_string('# This is a comment')
       
      puts "Result: #{result.inspect}"
       
      result = parser.parse_string <<-EOM
      # This is a comment
      $foo = 1
      EOM
       
      puts "Result: #{result.inspect}"
      

      The result is:

      # ruby parser_tst.rp 
      Result: nil
      Result: #<Puppet::Pops::Model::Factory:0x7ffe0c270dc8 @current=Puppet::Pops::Model::AssignmentExpression>
      

      In the first case, a nil is returned because there are no Puppet statements in the input. We should consider returning some Pops::Model object, such as Nop, instead of nil.

      Or, document nil as a valid return type for the future parser.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned
              Reporter:
              chuck Charlie Sharpsteen
              QA Contact:
              Kurt Wall
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Zendesk Support