The Puppet Labs Issue Tracker has Moved: https://tickets.puppetlabs.com

Bug #4638

Confusion between arrays and scalars in grammar

Added by Paul Berry about 4 years ago. Updated over 3 years ago.

Status:ClosedStart date:08/27/2010
Priority:NormalDue date:
Assignee:Jesse Wolfe% Done:

100%

Category:parser
Target version:2.7.0
Affected Puppet version: Branch:http://github.com/reductivelabs/puppet/tree/next
Keywords:

We've Moved!

Ticket tracking is now hosted in JIRA: https://tickets.puppetlabs.com

This issue is currently not available for export. If you are experiencing the issue described below, please file a new ticket in JIRA. Once a new ticket has been created, please add a link to it that points back to this Redmine ticket.


Description

In the grammar, when a construct can contain a variable number of objects, we generally represent it as an ASTArray when it contains more than one object (or zero objects) and a scalar object when it contains exactly one object. This saves a trivial amount of memory at the expense of complicating the code, because it forces all uses of these plural constructs to check whether they are accessing an array or a scalar, and alter their behavior accordingly.

In addition to complicating the code, it causes the parser to behave incorrectly in situations where an array contains other arrays, because while parsing an array the parser can’t reliably distinguish between an array nested inside another array and an array that hasn’t been completely parsed yet. As a result, [[[a, b], c], d] produces an identical parse result to [a, b, c, d]. Fortunately, this inconsistency has not been a problem so far because there aren’t any providers for which nested arrays are a useful construct. But it would be nice to fix the parser before such a situation arises.


Related issues

Related to Puppet - Bug #4633: Array flattening breaks idempotence Rejected 08/26/2010

History

#1 Updated by Paul Berry about 4 years ago

  • Status changed from Accepted to In Topic Branch Pending Review
  • % Done changed from 0 to 100
  • Branch set to http://github.com/stereotype441/puppet/tree/ticket/next/4638

I’ve pushed a patch that represents all grammar elements consistently either as an ASTArray (for grammar elements that can represent more than one thing) or a scalar object (for all other grammar elements).

#2 Updated by Jesse Wolfe about 4 years ago

  • Status changed from In Topic Branch Pending Review to Merged - Pending Release
  • Assignee changed from Paul Berry to Jesse Wolfe
  • Branch changed from http://github.com/stereotype441/puppet/tree/ticket/next/4638 to http://github.com/reductivelabs/puppet/tree/next

available in next as 6860594c4d95855d5106fbf664a473e1ac4d3935

#3 Updated by Nick Lewis almost 4 years ago

  • Status changed from Merged - Pending Release to Closed

#4 Updated by James Turnbull over 3 years ago

  • Target version changed from 2.7.x to 2.7.0

Also available in: Atom PDF