<div dir="ltr"><span id="docs-internal-guid-9fa1f1eb-6f1f-5bc8-4d22-75a1dfa66622"><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">In the final ECMAScript 2015 spec, each function for which </span><span style="font-family:Cambria;color:rgb(51,51,51);vertical-align:baseline;white-space:pre-wrap;background-color:rgb(253,253,252)">ContainsExpression</span><span style="font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"> of that function's </span><span style="font-family:Cambria;color:rgb(51,51,51);vertical-align:baseline;white-space:pre-wrap;background-color:rgb(253,253,252)">[[FormalParameters]]</span><span style="font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"> internal slot is true has a scope object for its parameters. Additionally, these functions have a separate scope object under this one for each parameter that has an initializer. See 14.1.18 for the production "</span><span style="font-family:'Times New Roman';color:rgb(51,51,51);font-style:italic;vertical-align:baseline;white-space:pre-wrap;background-color:rgb(253,253,252)">FormalParameter</span><span style="font-family:Cambria;color:rgb(51,51,51);vertical-align:baseline;white-space:pre-wrap;background-color:rgb(253,253,252)"> </span><span style="font-family:Cambria;color:rgb(51,51,51);font-weight:bold;vertical-align:baseline;white-space:pre-wrap;background-color:rgb(253,253,252)">:</span><span style="font-family:Cambria;color:rgb(51,51,51);vertical-align:baseline;white-space:pre-wrap;background-color:rgb(253,253,252)"> </span><span style="font-family:'Times New Roman';color:rgb(51,51,51);font-style:italic;vertical-align:baseline;white-space:pre-wrap;background-color:rgb(253,253,252)">BindingElement</span><span style="font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">". The last sentence of this section states</span></p><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt;margin-left:36pt"><span style="font-family:Cambria;color:rgb(51,51,51);vertical-align:baseline;white-space:pre-wrap;background-color:rgb(253,253,252)">The new </span><a href="http://www.ecma-international.org/ecma-262/6.0/index.html#sec-environment-records" style="text-decoration:none"><span style="font-family:Cambria;color:rgb(51,51,187);vertical-align:baseline;white-space:pre-wrap;background-color:rgb(253,253,252)">Environment Record</span></a><span style="font-family:Cambria;color:rgb(51,51,51);vertical-align:baseline;white-space:pre-wrap;background-color:rgb(253,253,252)"> created in step 6 is only used if the </span><span style="font-family:'Times New Roman';color:rgb(51,51,51);font-style:italic;vertical-align:baseline;white-space:pre-wrap;background-color:rgb(253,253,252)">BindElement</span><span style="font-family:Cambria;color:rgb(51,51,51);font-style:italic;vertical-align:baseline;white-space:pre-wrap;background-color:rgb(253,253,252)">’</span><span style="font-family:Cambria;color:rgb(51,51,51);vertical-align:baseline;white-space:pre-wrap;background-color:rgb(253,253,252)">s </span><span style="font-family:'Times New Roman';color:rgb(51,51,51);font-style:italic;vertical-align:baseline;white-space:pre-wrap;background-color:rgb(253,253,252)">Initializer</span><span style="font-family:Cambria;color:rgb(51,51,51);vertical-align:baseline;white-space:pre-wrap;background-color:rgb(253,253,252)"> contains a direct eval.</span></p><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">This is shown to be incorrect (aside from the "BindElement" typo) with the following program.</span></p><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt;margin-left:36pt"><span style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font face="monospace, monospace">var x = "outer";</font></span></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt;margin-left:36pt"><span style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font face="monospace, monospace">function f({ [eval('var x="inner"; "a";')]: y } = null) {</font></span></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt;margin-left:36pt"><span style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font face="monospace, monospace">  console.log(x);</font></span></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt;margin-left:36pt"><span style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font face="monospace, monospace">}</font></span></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt;margin-left:36pt"><span style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font face="monospace, monospace">f({a: "z"});</font></span></p><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">Because the presence of an initializer causes a new scope to be created, in which the entire BindingElement is evaluated, this should print "outer". Therefore, the scope is used any time there is a direct eval in BindingElement.</span></p><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">The intent, per the last sentence of 14.1.18 and </span><a href="https://bugs.ecmascript.org/show_bug.cgi?id=3383" style="text-decoration:none"><span style="font-family:Arial;text-decoration:underline;vertical-align:baseline;white-space:pre-wrap;background-color:transparent">bug 3383</span></a><span style="font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">, is that direct evals in the parameter list cannot introduce new variables in the function's parameters scope mentioned earlier. However, non-strict direct evals can also occur in computed property names in parameters which </span><span style="font-family:Arial;color:rgb(0,0,0);font-style:italic;vertical-align:baseline;white-space:pre-wrap;background-color:transparent">do not</span><span style="font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"> have initializers</span></p><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt;margin-left:36pt"><span style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font face="monospace, monospace">var x = "outer";</font></span></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt;margin-left:36pt"><span style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font face="monospace, monospace">function f({ [eval("var x='inner'; 'a';")]: y }) {</font></span></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt;margin-left:36pt"><span style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font face="monospace, monospace">  console.log(x);</font></span></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt;margin-left:36pt"><span style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font face="monospace, monospace">}</font></span></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt;margin-left:36pt"><span style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font face="monospace, monospace">f({a: "z"});</font></span></p><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">Because the separate scope is not created if no initializer is present, this should print "inner".</span></p><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">Introducing an initializer, even an initializer which is just a simple value, causes a separate scope to be created. This is non-intuitive, and appears to be unintentional.</span></p><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">There are multiple ways that this behavior can be fixed</span></p><br><ol style="margin-top:0pt;margin-bottom:0pt"><li dir="ltr" style="list-style-type:decimal;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;background-color:transparent"><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="vertical-align:baseline;white-space:pre-wrap;background-color:transparent">Create a new scope for each parameter, unconditionally</span></p></li><li dir="ltr" style="list-style-type:decimal;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;background-color:transparent"><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="vertical-align:baseline;white-space:pre-wrap;background-color:transparent">Create a new scope for parameters for which </span><span style="font-family:Cambria;color:rgb(51,51,51);vertical-align:baseline;white-space:pre-wrap;background-color:rgb(253,253,252)">ContainsExpression</span><span style="vertical-align:baseline;white-space:pre-wrap;background-color:transparent"> is true, instead of just those that have an initializer</span></p></li><li dir="ltr" style="list-style-type:decimal;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;background-color:transparent"><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="vertical-align:baseline;white-space:pre-wrap;background-color:transparent">Define code in computed property names as strict code</span></p></li></ol><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">The erroneous sentence at the end of section 14.1.18 may be fixed by replacing it with "The new Environment Record created in step 6 is only used if the BindElement contains a direct eval.".</span></p><div><span style="font-size:14.6666666666667px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><br></span></div></span></div>