« Bugzilla Issues Index

#174 — FutureReservedWords should not be allowed as a function name or argument name of a strict func.

+++ This bug was initially created as a clone of Bug #173 +++

this probably should go in the 5.1 errata


I don't think this is directly address by the specification but I think we have sufficient clues in the spec. to tell us how they should be handled.

10.1 and 10.1.1 defined "Function code" and "strict function code" as source text that is part of a FunctionBody. that would seem to exclude the function name and formal parameters. However, 13.1 explicitly applies strict mode restrictions concerning the use of "eval" and "arguments" to a "strict mode FunctionDeclaration or FunctionExpression". Unfortunately, the spec. doesn't appear to explicitly define "strict mode FunctionDeclaration" or "strict mode FunctionExpression". It does define "strict function code" but in a manner that only refers to the FunctionBody. However, the semantics of FunctionDeclaration and FunctionExpression in 13 treat the construction of a function as a strict function if its FunctionBody is strict code (meaning it contains a Use Strict Directive). In addition, 13.1 explicitly mentioned that strict mode restrictions on the use of "eval" and "arguments" or with duplicate parameter names apply to the formal parameters of FunctionDeclarations and

From this, I think we can reasonably conclude that the intent was that strict mode restriction apply to an entire FunctionDeclaration or FunctionExpression and not just the FunctionBody. The function name Identifier is syntactically part of a FunctionDeclaration or FunctionExpression so it would be consistent for any restrictions to also apply to it.

Also, note that the "backwards" impart of the already explicit formal parameter restrictions for strict mode functions is similar to what is required to also apply the FutureReservedWord restriction to either the function name or the formal parameters.

In addition, in the case of FunctionExpressions the only place the function name has a visible binding is within the FunctionBody. The only semantically significant reason to give a FunctionExpression a name is so it could be referenced from within its body but if its name was a FutureReservedWord and the FunctionBody contained a Use Strict Directive any reference to that name from the body would be illegal.

Finally, I can testify that if I had thought of it or if somebody had mentioned it I would have listed the FutureReservedWord restriction on function names and formal parameters in 13.1.

So, sorry, but I don't think I can simplify your life in this case. In the next errata FutureReservedWord errors for the function name and formal parameters should be added to 13.1.


set IN_PROGRESS to indicated this should go into ES5.1 Errata.

Bulk resolving ES5.1 errata issues as a sampling suggests these are all fixed. If this is in error, please open a new issue on GitHub.