Strictness of BindingIdentifiers of functions with "use strict" directives
# Mike (9 years ago)
There was a good discussion about this around this time last year on the ECMAScript BugZilla tracker:
Allen showed how this is a little less straightforward than it might first appear, but he proposed a solution that could work.
Consider the following code:
function static(){'use strict'}
.As far as I can tell, this is a legal Script. It would not be if
static
is considered to be in strict mode code, since it would then be a reserved word. However, the directive only makes the associated function code strict (10.2.1), which does not include its BindingIdentifier:Function code is defined to be "source text that is parsed to supply the value of the [[ECMAScriptCode]] and [[FormalParameters]] internal slots of an ECMAScript function object" (10.2). In particular, this does not appear to include the name of a function declaration or expression.
Despite its apparent legality, all of [v8, SpiderMonkey, JavaScriptCore, ChakraCore, Nashorn] do not allow it, nor does any parser I tried except Shift.
Is this intended to be legal?