facebookarchive / hack-langspec

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

Master #78

Closed ericlippert closed 8 years ago

ericlippert commented 8 years ago

(1) The grammar suggests that the "namespace foo { }" form contains a block of statements, but in fact it contains a block of declarations.

I've also eliminated the problematic use of "scope" to mean "definition extent". We already define "scope" as the region of program text in which a given name is visible, so we should not use "scope" to mean the region of program text which belongs syntactically to a namespace definition.

(2) The link to the cast operator was wrong.

(3) Chapters 10, 15 and 22 were inconsistent in their treatment of "noreturn" return types. Anonymous functions can simply re-use the return-type production, and we add "noreturn" to that production consistently.

(4) The grammar for enum bodies implied that enum items were separated by semicolons when in fact they are terminated by semicolons. That is, there must be a trailing semicolon on every item including the last one.

(5) The grammar for methods as being a special kind of function was wrong in a small way. Fixed.

(6) The spec for switch statements did not say that the first thing inside the block must be a case or default. Fixed.

(7) The "require" clauses were not specified as ending with semicolons.

(8) Hack allows ": void" annotations on constructors and destructors. I added this feature to the grammar.

(9) A named function / method formal parameter list may end in a comma if not empty and not ending with "..."

(10) A lambda / anonymous method formal parameter list may have a "..." and, similar to (9), may end in a comma.

(11) The grammar for the formal parameter of a catch clause was needlessly permissive and complex; I've simplified it greatly.

(12) The "anonymous-function-body" production is nowhere used in anonymous functions; it's only used in lambdas. I've renamed it "lambda-body".

(13) "generic-type-parameter-list" was used in many places where "generic-type-argument-list" was intended.

(14) The grammar for function call and constructor call argument lists was different in ch 22 than where it was introduced; also, it should allow a trailing comma.

(15) Generic type argument lists, generic type parameter lists, tuple type specifiers and type lists in function types all allow a trailing comma.

(16) "class" was formatted as a non-terminal rather than as a terminal.

(17) The scope resolution (::) operator grammar did not allow a variable name on the right hand side.

(18) The object creation (new) grammar did not allow a scope resolution (::) expression or member selection (->) or subscript ([]) in the type designator; Hack allows all of these.

(19) The member selection (-> and ?->) operator grammars did not allow a variable on the right hand side.

(20) The "namespace use" documentation did not include function and const aliases or the "group" syntax.

(21) A shape's field specifier or initializer may have a scope resolution (foo::bar) on the left hand side of the arrow.

(22) Simplified the description and grammar for type aliases; added generic type parameter list to type aliases.

(23) A type alias can have an attribute.

(24) The grammar of the inclusion directive was unnecessarily complicated. I simplified it.

(25) The argument of a classname type can be generic.

JoelMarcey commented 8 years ago

@RexJaeschke reviewed this as well. He says looks good. So I am going to merge this.