Skip to content

Commit b3aeb58

Browse files
committed
spec: Change Contains to ContainsOuterTopic
Fixes #226.
1 parent 3a9ac07 commit b3aeb58

File tree

1 file changed

+46
-50
lines changed

1 file changed

+46
-50
lines changed

spec.html

Lines changed: 46 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -105,46 +105,48 @@ <h1>Static Semantics: IsIdentifierRef</h1>
105105
<emu-clause id="sec-syntax-directed-operations-contains">
106106
<h1>Contains</h1>
107107

108-
<emu-note type=editor>
109-
<p>This section augments the <a
110-
href=https://tc39.es/ecma262/#sec-syntax-directed-operations-contains>original
111-
Contains clause</a>.</p>
108+
<emu-clause id="sec-static-semantics-ContainsOuterTopic" type="sdo" aoid="ContainsOuterTopic">
109+
<h1>Static Semantics: ContainsOuterTopic</h1>
110+
<emu-note type=editor>
111+
<p>This section is a wholly new sub-clause of the <a
112+
href=https://tc39.github.io/ecma262/#sec-syntax-directed-operations-contains
113+
>original Contains clause</a>.</p>
114+
</emu-note>
112115

113-
<p>It presumptively uses `%` as the placeholder token for the
114-
topic reference. This choice of token is not a final decision; `%`
115-
could instead be `^` or some other token.</p>
116-
</emu-note>
116+
<emu-note>
117+
<p>Several early error rules for |ScriptBody| and for
118+
|ModuleItemList|, as well as a step in CreateDynamicFunction,
119+
use the ContainsOuterTopic operation to check for any unbound topic reference `%`.
120+
Any inner topic reference within a |PipeBody| is hidden from these rules,
121+
preventing them from triggering the rules during program
122+
compilation.</p>
117123

118-
<emu-clause id="sec-static-semantics-contains" type="sdo" aoid="Contains">
119-
<h1>Static Semantics: Contains</h1>
120-
<p>With parameter _symbol_.</p>
124+
<p>This guarantees that any topic reference in a program must be
125+
present within a topic-binding environment
126+
created by a |PipeBody| within that program.</p>
127+
</emu-note>
121128

122-
<ins class=block>
123-
<emu-grammar>PipeBody : PipeExpression</emu-grammar>
129+
<p>Every grammar production alternative in this specification which is not listed below implicitly has the following default definition of ContainsOuterTopic:</p>
124130

125-
<emu-alg>
126-
1. If _symbol_ is `%`, return *false*.
131+
<emu-alg>
127132
1. For each child node _child_ of this Parse Node, do
128-
1. If _child_ is an instance of _symbol_, return *true*.
129-
1. If _child_ is an instance of a nonterminal, then
130-
1. Let _contained_ be the result of _child_ Contains _symbol_.
131-
1. If _contained_ is *true*, return *true*.
133+
1. If _child_ is an instance of `%`, return *true*.
134+
1. If _child_ is an instance of a nonterminal, and if ContainsOuterTopic of _child_ is *true*, return *true*.
132135
1. Return *false*.
133-
</emu-alg>
136+
</emu-alg>
134137

135-
<emu-note>
136-
<p>Several early error rules for |ScriptBody| and for
137-
|ModuleItemList|, as well as a step in CreateDynamicFunction,
138-
use the Contains operation to check for any unbound topic reference `%`.
139-
Any inner topic reference within a |PipeBody| is hidden from these rules,
140-
preventing them from triggering the rules during program
141-
compilation.</p>
138+
<emu-grammar>MultiplicativeExpression : MultiplicativeExpression MultiplicativeOperator ExponentiationExpression</emu-grammar>
142139

143-
<p>This guarantees that any topic reference in a program must be
144-
present within a topic-binding environment
145-
created by a |PipeBody| within that program.</p>
146-
</emu-note>
147-
</ins>
140+
<emu-alg>
141+
1. If ContainsOuterTopic of |MultiplicativeExpression| is *true*, or if ContainsOuterTopic of |ExponentiationExpression| is *true*, return *true*.
142+
1. Return *false*.
143+
</emu-alg>
144+
145+
<emu-grammar>PipeBody : AssignmentExpression</emu-grammar>
146+
147+
<emu-alg>
148+
1. Return *false*.
149+
</emu-alg>
148150
</emu-clause>
149151
</emu-clause>
150152

@@ -629,9 +631,7 @@ <h1><ins>Topic Reference</ins></h1>
629631
All unbound topic references are invalid syntax.
630632
Several early error rules for |ScriptBody| and for
631633
|ModuleItemList|, as well as a step in CreateDynamicFunction,
632-
use the
633-
<emu-xref href="#sec-syntax-directed-operations-contains">Contains</emu-xref>
634-
operation to check for any unbound topic reference `%`.
634+
use ContainsOuterTopic to check for any unbound topic reference `%`.
635635
Any inner topic reference within a |PipeBody| is hidden from these rules,
636636
preventing them from triggering the rules during program
637637
compilation.</p>
@@ -649,9 +649,7 @@ <h1>Runtime Semantics: Evaluation</h1>
649649
This is syntactically enforced by early error rules
650650
for |ScriptBody| and for |ModuleItemList|,
651651
as well as a step in CreateDynamicFunction.
652-
These rules use the
653-
<emu-xref href="#sec-syntax-directed-operations-contains">Contains</emu-xref>
654-
operation to check for any unbound topic reference.</p>
652+
These rules use ContainsOuterTopic to check for any unbound topic reference.</p>
655653
</emu-note>
656654

657655
<emu-grammar>PrimaryExpression : `%`</emu-grammar>
@@ -692,22 +690,20 @@ <h1>Static Semantics: Early Errors</h1>
692690
could instead be `^` or some other token.</p>
693691
</emu-note>
694692

695-
<emu-grammar>PipeBody : PipeExpression</emu-grammar>
693+
<emu-grammar>PipeBody : AssignmentExpression</emu-grammar>
696694
<emu-alg>
697-
1. It is a Syntax Error if |PipeBody| Contains `%` is *false*.
695+
1. It is a Syntax Error if |PipeBody| ContainsOuterTopic is *false*.
698696
</emu-alg>
699697

700698
<emu-note>
701699
<p>A |PipeBody| must use its topic at least once.
702700
`value |&gt; foo + 1` is an early error,
703-
because its |PipeBody| does not
704-
<emu-xref href="#sec-syntax-directed-operations-contains">contain</emu-xref>
705-
a topic reference `%`.
701+
because ContainsOuterTopic of its |PipeBody| is *false*.
706702
This design is such because omission of any topic reference from a |PipeBody|
707703
is almost certainly an accidental programmer error.</p>
708704
</emu-note>
709705

710-
<emu-grammar>PipeBody : PipeExpression</emu-grammar>
706+
<emu-grammar>PipeBody : AssignmentExpression</emu-grammar>
711707
<emu-alg>
712708
1. It is a Syntax Error if one of the following productions is covering |PipeBody|:
713709
* |ShortCircuitExpression| ? |AssignmentExpression| : |AssignmentExpression|
@@ -775,12 +771,12 @@ <h1>Static Semantics: Early Errors</h1>
775771
<emu-grammar>Script : ScriptBody</emu-grammar>
776772
<ul>
777773
<li>
778-
<ins>It is a Syntax Error if |ScriptBody| Contains `%` is *true*.</ins>
774+
<ins>It is a Syntax Error if ContainsOuterTopic of |ScriptBody| is *true*.</ins>
779775
</li>
780776
</ul>
781777
<ins class="block">
782778
<emu-note>
783-
<p>An early error rule uses the Contains operation
779+
<p>An early error rule uses ContainsOuterTopic
784780
to check for any unbound topic reference.
785781
Any inner topic reference within a |PipeBody| is hidden from this rule,
786782
preventing them from triggering the rule during program
@@ -815,14 +811,14 @@ <h1>Static Semantics: Early Errors</h1>
815811
<emu-grammar>ModuleBody : ModuleItemList</emu-grammar>
816812
<ul>
817813
<li>
818-
<ins>It is a Syntax Error if |ModuleItemList| Contains `%`
814+
<ins>It is a Syntax Error if ContainsOuterTopic of |ModuleItemList|
819815
is *true*.</ins>
820816
</li>
821817
</ul>
822818

823819
<ins class="block">
824820
<emu-note>
825-
<p>An early error rule uses the Contains operation
821+
<p>An early error rule uses ContainsOuterTopic
826822
to check for any unbound topic reference.
827823
Any inner topic reference within a |PipeBody| is hidden from this rule,
828824
preventing them from triggering the rule during program
@@ -917,8 +913,8 @@ <h1>CreateDynamicFunction ( _constructor_, _newTarget_, _kind_, _args_ )</h1>
917913
1. NOTE: If this step is reached, _sourceText_ must match _exprSym_ (although the reverse implication does not hold). The purpose of the next two steps is to enforce any Early Error rules which apply to _exprSym_ directly.
918914
1. Let _expr_ be ParseText(_sourceText_, _exprSym_).
919915
1. If _expr_ is a List of errors, throw a *SyntaxError* exception.
920-
1. <ins>NOTE: The dynamic function must not <emu-xref href="#sec-syntax-directed-operations-contains">contain</emu-xref> an unbound topic reference `%`.)</ins>
921-
1. <ins>If _expr_ Contains `%` is *true*, throw a *SyntaxError* exception.</ins>
916+
1. <ins>NOTE: The dynamic function must not contain an unbound topic reference `%`.)</ins>
917+
1. <ins>If ContainsOuterTopic of _expr_ is *true*, throw a *SyntaxError* exception.</ins>
922918
1. Let _proto_ be ? GetPrototypeFromConstructor(_newTarget_, _fallbackProto_).
923919
1. Let _realmF_ be the current Realm Record.
924920
1. Let _scope_ be _realmF_.[[GlobalEnv]].

0 commit comments

Comments
 (0)