facebookarchive / hack-langspec

The official Hack Language specification.
http://hacklang.org
Other
172 stars 48 forks source link

Error in ch 20 regarding nested namespaces #96

Open ericlippert opened 7 years ago

ericlippert commented 7 years ago

Chapter 20 makes the following statements about namespaces:

(1)

"All occurrence of a namespace-definition in a script must have the declaration-list form or must have the "semicolon" form; the two forms cannot be mixed."

This is correct.

(2) "The declaration-list must not contain a namespace-definition."

This is not correct. It should be legal to say

namespace foo { namespace bar { class C { } } new \foo\bar\C(); }

Now, it should still be illegal to say

namespace foo { namespace bar;

and so on, but this is covered by the first rule.

The second rule can simply be deleted.

ericlippert commented 7 years ago

Note that this is an area where Hack deliberately diverges from PHP; nested namespaces in this style are illegal in PHP.