Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(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...
- Loading branch information
Showing
5 changed files
with
57 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters