FunctionDeclaration as an element of a Block statement's StatementList

Allen Wirfs-Brock allen at
Tue May 20 14:03:13 PDT 2014

On May 20, 2014, at 12:58 PM, Garrett Smith wrote:

> "Prior to the Sixth Edition, the ECMAScript specification did not
> define the occurrence of a FunctionDeclaration as an element of a
> Block statement's StatementList."
> The problem is not necessarily that FunctionDeclaration appears in a
> Block, that FunctionDeclatation appears  in places in a program where
> a Statement is permitted but a FunctionDeclaration is not.
> ES5 mentioned it:
> "Several widely used implementations of ECMAScript are known to
> support the use of FunctionDeclaration as a Statement."
> I don't have a concrete proposal, but I wonder why specifying as ES6
> does makes less sense to take the text that ES5 had in s 12 and
> attempt to codify, as ES6 does, except using Statement instead of
> StatementList.

Because we don't know what an apparent conditional declaration, eg:

   if (predicate) function foo() { };

should mean in the context of ES6's declaration rules.  While on the other hand, it is really clear what the meaning of

  if (predicate) {function foo() {}}

should if you apply the ES6 declaration rules.

So the only issue is what hacks do we have to provide to keep currently interoperable (among multiple browsers) code working that has some sort of legacy use of FunctionDeclaration in a Statement context.  It turns out that T39 conclude that a naked FunctionDeclaration in a conditional statement context is not in the current interoperable intersection semantics and hence we don't need special hacks to support it.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list