Standardizing allowed visibility modifiers on methods inside interfaces
commit612a3f313e83cf36077f53493d5eb03aee886477
authorElena Polozova <elenapolozova@fb.com>
Wed, 5 Jul 2017 23:16:24 +0000 (5 16:16 -0700)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Wed, 5 Jul 2017 23:22:02 +0000 (5 16:22 -0700)
treee63ba72bd2ca4643747901869f955d1ff59a587b
parent7994cf455c791e37a93d68dc952b1d28988118c3
Standardizing allowed visibility modifiers on methods inside interfaces

Summary:
Overview: I've added error2047 (about visibility modifiers--protected, private, and public) to ensure consistency between the code accepted by the full fidelity parser and HHVM.

More information:

Prior to this diff, the full fidelity and original parsers would accept (otherwise-correct) methods with any visibility modifier inside of an interface. The full fidelity parser in particular would even allow omitting the modifier entirely. (The original parser would not--it threw the error "line 4, characters 3-10: Expected modifier (Parsing[1002])" on the code in test_visibility_modifier_errors.php.)

However, HHVM throws errors on methods declared 'private' or 'protected' inside of an interface. It throws the following errors on code in test_visibility_modifier_errors.php:

Fatal error: Access type for interface method I1::i3() must be omitted ... on line 6.

Fatal error: Access type for interface method I1::i3() must be omitted ... on line 7.

That said, HHVM does allow omitting the visibility modifier--it parses line 4 just fine.

By adding error2047, I've made sure that the full fidelity parser agrees with HHVM on which visibility modifiers are acceptable inside of interfaces.

(The Hack spec currently doesn't allow dropping the 'public', but Eric has submitted a spec issue asking them to relax that constraint.)

Reviewed By: ericlippert

Differential Revision: D5352850

fbshipit-source-id: 6b539dac69e097207739823362fdcf7eca417af6
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_visibility_modifier_errors.exp [new file with mode: 0644]
hphp/hack/test/full_fidelity/cases/test_visibility_modifier_errors.php [new file with mode: 0644]
hphp/hack/test/full_fidelity/full_fidelity_unit_test.ml