You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: spec.html
+13-12
Original file line number
Diff line number
Diff line change
@@ -18622,17 +18622,7 @@ <h2>Syntax</h2>
18622
18622
<p>|MethodDefinition| is defined in <emu-xref href="#sec-method-definitions"></emu-xref>.</p>
18623
18623
</emu-note>
18624
18624
<emu-note>
18625
-
<p>In certain contexts, |ObjectLiteral| is used as a cover grammar for a more restricted secondary grammar. The |CoverInitializedName| production is necessary to fully cover these secondary grammars. However, use of this production results in an early Syntax Error in normal contexts where an actual |ObjectLiteral| is expected.</p>
18626
-
<p>For example, consider:</p>
18627
-
<pre><code class="javascript">
18628
-
let o = {f = 1};
18629
-
</code></pre>
18630
-
<p>`{f = 1}` is parsed as an |ObjectLiteral| with a |CoverInitializedName|, which results in a Syntax Error via one of the early error rules in the next section.</p>
18631
-
<p>In contrast, consider:</p>
18632
-
<pre><code class="javascript">
18633
-
({f = 1} = {f: 2});
18634
-
</code></pre>
18635
-
<p>Here, `{f = 1}` is again initially parsed as an |ObjectLiteral| with a |CoverInitializedName|, but since it's the |LeftHandSideExpression| of an |AssignmentExpression|, it must cover an |AssignmentPattern|, so the |ObjectLiteral| and |CoverInitializedName| are not subject to early error rules. Instead, `{f = 1}` is reparsed as an |ObjectAssignmentPattern| with an |AssignmentProperty|, and there is no Syntax Error.</p>
18625
+
<p>See the next section for the significance of |CoverInitializedName|.</p>
@@ -18666,7 +18656,18 @@ <h1>Static Semantics: Early Errors</h1>
18666
18656
</li>
18667
18657
</ul>
18668
18658
<emu-note>
18669
-
<p>This production exists so that |ObjectLiteral| can serve as a cover grammar for |ObjectAssignmentPattern|. It cannot occur in an actual object initializer.</p>
18659
+
<p>Elsewhere in this specification, there are early error rules that, under certain circumstances, require that a |LeftHandSideExpression| must cover an |AssignmentPattern|. Consequently, |ObjectLiteral| serves as a cover grammar for |ObjectAssignmentPattern|. The |CoverInitializedName| production is necessary to fully cover |AssignmentProperty|, but is not valid within an actual object initializer.</p>
18660
+
<p>Specifically, in a context where an actual |ObjectLiteral| is expected, the above early error rule prevents the use of |CoverInitializedName|. But in cases where |ObjectLiteral| is used as a cover grammar, the semantics of "must cover" state that the Parse Nodes within the |ObjectLiteral| are not subject to early error rules, and so |CoverInitializedName| is allowed.</p>
18661
+
<p>For example, consider:</p>
18662
+
<pre><code class="javascript">
18663
+
let o = {f = 1};
18664
+
</code></pre>
18665
+
<p>`{f = 1}` is parsed as an |ObjectLiteral| with a |CoverInitializedName|, which results in a Syntax Error via this early error rule.</p>
18666
+
<p>In contrast, consider:</p>
18667
+
<pre><code class="javascript">
18668
+
({f = 1} = {f: 2});
18669
+
</code></pre>
18670
+
<p>Here, `{f = 1}` is again initially parsed as an |ObjectLiteral| with a |CoverInitializedName|, but since it's the |LeftHandSideExpression| of an |AssignmentExpression|, it must cover an |AssignmentPattern|, so the |ObjectLiteral| and |CoverInitializedName| are not subject to early error rules. Instead, `{f = 1}` is reparsed as an |ObjectAssignmentPattern| with an |AssignmentProperty|, and there is no Syntax Error.</p>
0 commit comments