Fix code for parsing "new" expressions
commita4b8dee9c6453786dcbfeb2859b6d31db6f3d4b2
authorEric Lippert <ericlippert@fb.com>
Mon, 29 Aug 2016 21:02:00 +0000 (29 14:02 -0700)
committerHhvm Bot <hhvm-bot-bot@fb.com>
Mon, 29 Aug 2016 21:03:02 +0000 (29 14:03 -0700)
treeaa43a9025ab39cdc1a614c20a6d775c1faa9ba28
parent5615e8048ae74cfcf9c8ad505b5490ea49aeb61c
Fix code for parsing "new" expressions

Summary:
Parsing object creation expressions was a bit messed up.

I have determined what the rule is in Hack for the operand of a "new"; it must be parent, self, static, a qualified name, a variable, or a use of ->, ?->, [], {} or ::,  I've updated the spec with this information and added a comment to the code.

The most expedient thing to do here is to parse any expression, but that doesn't quite work because in "new x()", "x()" is an expression! So what we do is parse any expression with the precedence of "new".  Since () is of lower precedence than new, "x()" will be parsed as "x".

We'll then add an error checker to a later pass in another diff.

Reviewed By: jopamer

Differential Revision: D3757834

fbshipit-source-id: fce9d93e51dd5d0af1ff9c22b7470efacb3c9092
hphp/hack/src/full_fidelity/full_fidelity_expression_parser.ml
hphp/hack/src/full_fidelity/full_fidelity_precedence_parser.ml