Fix precedence of "await" and some erroneous test cases
commit2f9020b3c0996e334de149b9c0313a8e2f7d6bb1
authorEric Lippert <ericlippert@fb.com>
Thu, 25 Aug 2016 21:27:37 +0000 (25 14:27 -0700)
committerHhvm Bot <hhvm-bot-bot@fb.com>
Thu, 25 Aug 2016 21:37:42 +0000 (25 14:37 -0700)
treee6857f7bd29aad09bb7c4daf9b2e7989fb2c2561
parent36eee582821f82cba084ce07b0e6bf4dc733f564
Fix precedence of "await" and some erroneous test cases

Summary:
While working on getting the full-fidelity parser behaviour for -> correct, I noticed that one of the test cases was wrong in two ways. The test was intended to determine whether the "array" built-in was being parsed correctly, but the case was wrong; it was:

    await $x->array( ... )

The intention of the test was to have the right side of the -> parsed as an expression, but a name immediately following -> should always be parsed as the member of the receiver. That is, this should be

   await ( ($x->array) ( ... ) )

and not

    await ( $x-> ( array ( ... ) ) )

I changed the -> to a . so that we do not have this problem.

Second, the "await" operator should be the lowest precedence operator, but for some reason which escapes me, I had it on the precedence list with casts, which is wrong. This meant that another test case was getting the wrong answer:

    await $x + $y

should be parsed as

    await ($x + $y)

and not

    (await $x) + $y

I changed the precedence and fixed the test case.

At some point we should get the precedence rules in a table in the spec, but that can come later.

Reviewed By: jamesjwu

Differential Revision: D3753588

fbshipit-source-id: 57d140fd1da4461f63fab5a84b668a626e9e4a1a
hphp/hack/src/full_fidelity/full_fidelity_expression_parser.ml
hphp/hack/src/full_fidelity/full_fidelity_operator.ml
hphp/hack/test/full_fidelity/cases/test_array_key_value_precedence.exp
hphp/hack/test/full_fidelity/cases/test_array_key_value_precedence.php
hphp/hack/test/full_fidelity/cases/test_list_precedence.exp