The Puppet Labs Issue Tracker has Moved:

This issue tracker is now in read-only archive mode and automatic ticket export has been disabled. Redmine users will need to create a new JIRA account to file tickets using See the following page for information on filing tickets with JIRA:

Bug #4638

Confusion between arrays and scalars in grammar

Added by Paul Berry over 5 years ago. Updated almost 5 years ago.

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


Target version:2.7.0
Affected Puppet version: Branch:

We've Moved!

Ticket tracking is now hosted in JIRA:


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


#1 Updated by Paul Berry over 5 years ago

  • Status changed from Accepted to In Topic Branch Pending Review
  • % Done changed from 0 to 100
  • Branch set to

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 over 5 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 to

available in next as 6860594c4d95855d5106fbf664a473e1ac4d3935

#3 Updated by Nick Lewis over 5 years ago

  • Status changed from Merged - Pending Release to Closed

#4 Updated by James Turnbull almost 5 years ago

  • Target version changed from 2.7.x to 2.7.0

Also available in: Atom PDF