Jira (PUP-9968) Parser does not allow comma after last element in nested Variant Types

0 views
Skip to first unread message

Reinhard Vicinus (JIRA)

unread,
Aug 20, 2019, 7:46:03 AM8/20/19
to puppe...@googlegroups.com
Reinhard Vicinus created an issue
 
Puppet / Bug PUP-9968
Parser does not allow comma after last element in nested Variant Types
Issue Type: Bug Bug
Affects Versions: PUP 6.7.2
Assignee: Unassigned
Components: Compiler
Created: 2019/08/20 4:45 AM
Priority: Minor Minor
Reporter: Reinhard Vicinus

Puppet Version: 6.7.2
Puppet Server Version: 6.5.0
OS Name/Version: Ubuntu 18.04.3 LTS

The following code does not parse:

type A = Variant[Pattern[/a/]]
type B = Variant[
  A,
]
 
define x (
  Variant[
    A,
  ] $a,
) {
}

with the following error:

Error: Could not parse for environment production: Syntax error at ']' (file: ~/test.pp, line: 9, column: 3)

Desired Behavior:

The code should be parsed without error.

Actual Behavior:

The parsing the code with puppet parser validate ~/test.pp throws the above mentioned error.

The code does parse if the comma behind type A in the Variant block is removed. But this is a inconsistent behavior, because, as far as i know, all array like enumerations in puppet allow a comma after the last element. Also it works if the type is declared with the type keyword. And it works if the elements in the enumeration are not Variants themselves.

 

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Henrik Lindberg (JIRA)

unread,
Aug 20, 2019, 10:24:02 AM8/20/19
to puppe...@googlegroups.com

Henrik Lindberg (JIRA)

unread,
Aug 20, 2019, 10:33:03 AM8/20/19
to puppe...@googlegroups.com
Henrik Lindberg commented on Bug PUP-9968
 
Re: Parser does not allow comma after last element in nested Variant Types

This is indeed a bug in the egrammar.ra - on line 728 there is an endcomma missing

parameter_type
  : type { result = val[0] }
  | type LBRACK access_args RBRACK { result = val[0].access(val[2]) ; loc result, val[0], val[3] }

It should be changed to this:

parameter_type
  : type { result = val[0] }
  | type LBRACK access_args endcomma RBRACK { result = val[0].access(val[2]) ; loc result, val[0], val[4] }

  • Adding endcomma
  • Adjusting val[3] to val[4] since there is now an additional rule and it should be a reference the RBRACK rule's value - which now is number 4.

With appropriate tests added.

Jorie Tappa (JIRA)

unread,
Oct 7, 2019, 2:52:03 PM10/7/19
to puppe...@googlegroups.com

Jorie Tappa (JIRA)

unread,
Oct 7, 2019, 2:52:03 PM10/7/19
to puppe...@googlegroups.com

David McTavish (Jira)

unread,
Dec 1, 2021, 11:44:02 AM12/1/21
to puppe...@googlegroups.com
David McTavish updated an issue
Change By: David McTavish
Labels: low-hanging-fruit
This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo

Josh Cooper (Jira)

unread,
Dec 2, 2021, 12:29:02 AM12/2/21
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Dec 2, 2021, 12:29:02 AM12/2/21
to puppe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages