Skip to content

Commit 9dc5ad6

Browse files
committed
Editorial: Delete now-redundant para + add example
In the section about early errors of ObjectLiterals, delete the paragraph about the non-application of some rules in some cases. But add a related example to the previous section.
1 parent 4b80bcf commit 9dc5ad6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

spec.html

+10-1
Original file line numberDiff line numberDiff line change
@@ -18402,6 +18402,16 @@ <h2>Syntax</h2>
1840218402
</emu-note>
1840318403
<emu-note>
1840418404
<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>
18405+
<p>For example, consider:</p>
18406+
<pre><code class="javascript">
18407+
let o = {f = 1};
18408+
</code></pre>
18409+
<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>
18410+
<p>In contrast, consider:</p>
18411+
<pre><code class="javascript">
18412+
({f = 1} = {f: 2});
18413+
</code></pre>
18414+
<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>
1840518415
</emu-note>
1840618416

1840718417
<emu-clause id="sec-object-initializer-static-semantics-early-errors" oldids="sec-__proto__-property-names-in-object-initializers">
@@ -18415,7 +18425,6 @@ <h1>Static Semantics: Early Errors</h1>
1841518425
It is a Syntax Error if PrivateBoundIdentifiers of |MethodDefinition| is not empty.
1841618426
</li>
1841718427
</ul>
18418-
<p>In addition to describing an actual object initializer the |ObjectLiteral| productions are also used as a cover grammar for |ObjectAssignmentPattern| and may be recognized as part of a |CoverParenthesizedExpressionAndArrowParameterList|. When |ObjectLiteral| appears in a context where |ObjectAssignmentPattern| is required the following Early Error rules are <b>not</b> applied. In addition, they are not applied when initially parsing a |CoverParenthesizedExpressionAndArrowParameterList| or |CoverCallExpressionAndAsyncArrowHead|.</p>
1841918428
<emu-grammar>PropertyDefinition : CoverInitializedName</emu-grammar>
1842018429
<ul>
1842118430
<li>

0 commit comments

Comments
 (0)