Detect mixed namespace declarations in Hack
commit9e04bda18fa642520e7030fd804480c7f7d4475d
authorBraden Watling <bradenwatling@fb.com>
Thu, 31 Aug 2017 17:25:22 +0000 (31 10:25 -0700)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Thu, 31 Aug 2017 17:38:27 +0000 (31 10:38 -0700)
treebdb3e044052571c5ce3c3d1bea7ec9554ebef09e
parent4fa3c3b921f182497088c39dd66c74c9134d9d0f
Detect mixed namespace declarations in Hack

Summary:
Modify the Full Fidelity Parser to prevent files from containing namespaces with and without bodies at the same time. For example the following would not be legal:

  <?hh // strict
  namespace foo {}
  namespace bar;

Also made sure the error message for this is logical.

Reviewed By: ericlippert

Differential Revision: D5683402

fbshipit-source-id: e233fac5ce33ac0d74a64026725279d1b7491821
12 files changed:
hphp/hack/src/parser/full_fidelity_declaration_parser.ml
hphp/hack/src/parser/full_fidelity_parser_errors.ml
hphp/hack/src/parser/full_fidelity_syntax_error.ml
hphp/hack/test/full_fidelity/cases/test_mixed_bracketed_unbracketed_namespaces1.exp [new file with mode: 0644]
hphp/hack/test/full_fidelity/cases/test_mixed_bracketed_unbracketed_namespaces1.php [new file with mode: 0644]
hphp/hack/test/full_fidelity/cases/test_mixed_bracketed_unbracketed_namespaces2.exp [new file with mode: 0644]
hphp/hack/test/full_fidelity/cases/test_mixed_bracketed_unbracketed_namespaces2.php [new file with mode: 0644]
hphp/hack/test/full_fidelity/cases/test_namespace_error_recovery.exp
hphp/hack/test/full_fidelity/cases/test_namespace_error_recovery.php
hphp/hack/test/full_fidelity/full_fidelity_unit_test.ml
hphp/hack/test/hackfmt/tests/namespaces.php
hphp/hack/test/hackfmt/tests/namespaces.php.exp