[puppetlabs/puppet] a0fbc5: (PUP-3363) Make transformation of unparenthesized ...

0 views
Skip to first unread message

GitHub

unread,
Oct 3, 2014, 8:30:26 PM10/3/14
to puppet-...@googlegroups.com, puppet...@googlegroups.com
Branch: refs/heads/stable
Home: https://github.com/puppetlabs/puppet
Commit: a0fbc519192c3e0d48e72d2545f901943c8edbe5
https://github.com/puppetlabs/puppet/commit/a0fbc519192c3e0d48e72d2545f901943c8edbe5
Author: Henrik Lindberg <henrik....@cloudsmith.com>
Date: 2014-10-03 (Fri, 03 Oct 2014)

Changed paths:
M lib/puppet/pops/model/factory.rb
M lib/puppet/pops/parser/egrammar.ra
M lib/puppet/pops/parser/eparser.rb
M lib/puppet/pops/parser/parser_support.rb
M spec/unit/pops/parser/parse_calls_spec.rb

Log Message:
-----------
(PUP-3363) Make transformation of unparenthesized calls handle errors

This fixes problems when a user enters commas where they are not
supposed to be. As a result, an expression will be parsed as being an
argument list for an unparenthesized function call. The transformation
logic for such calls did not take one case into account; a non call
followed by an argument list. e.g:

$a = 1,10

Which resulted in a strange AST model (a literal list with an assignment
and a 10).

This commit adds error checking and raising of an exception in the
transformation which is caught by parser_support and formatted into an
error - either about an illegal comma (when the LHS cannot possibly be
a call at all (as in the above exampel), or a more elaborate
message about that what could be a function call requires parentheses.

In order to enable positioning of the error message on the first comma
in the argumet list, the comma tokens were required in the expression
list fed to the transformer. Subsequently these tokens must be filtered
out by the transformation, and passed on in the raised exception (since
the receiver would otherwise not know which token that caused the
problem (it is nested inside the stucture it passes on to be
transformed).

Unparenthesized function calls are a very bad idea...


Commit: 200cf47b9aa3d54b81fdbb51b816af5688a7a766
https://github.com/puppetlabs/puppet/commit/200cf47b9aa3d54b81fdbb51b816af5688a7a766
Author: Andrew Parker <an...@puppetlabs.com>
Date: 2014-10-03 (Fri, 03 Oct 2014)

Changed paths:
M lib/puppet/pops/model/factory.rb
M lib/puppet/pops/parser/egrammar.ra
M lib/puppet/pops/parser/eparser.rb
M lib/puppet/pops/parser/parser_support.rb
M spec/unit/pops/parser/parse_calls_spec.rb

Log Message:
-----------
Merge pull request #3154 from hlindberg/PUP-3363_trailing-comma-assign

(PUP-3363) Make transformation of unparenthesized calls handle errors


Compare: https://github.com/puppetlabs/puppet/compare/e19552a09825...200cf47b9aa3
Reply all
Reply to author
Forward
0 new messages