The Puppet Labs Issue Tracker has Moved: https://tickets.puppetlabs.com
Confusion between arrays and scalars in grammar
|Assignee:||Jesse Wolfe||% Done:|
|Affected Puppet version:||Branch:||http://github.com/reductivelabs/puppet/tree/next|
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.
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.
#1 Updated by Paul Berry over 3 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 over 3 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