This repository has been archived by the owner on Jan 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
spec.html
3070 lines (2627 loc) · 145 KB
/
spec.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<pre class=metadata>
title: Smart Pipelines
status: proposal
stage: 0
location: https://github.com/js-choi/proposal-smart-pipelines
copyright: false
contributors: J. S. Choi
</pre>
<script src=ecmarkup.js defer></script>
<link rel=stylesheet href=ecmarkup.css>
<emu-intro id=introduction>
<h1>Introduction</h1>
<p>This is the formal specification for a proposed "smart pipe operator" <code>|></code> in JavaScript. It modifies the original <a href=https://tc39.github.io/ecma262/>ECMAScript specification</a> with several new or revised clauses. The <strong>Core Proposal</strong> is at Stage 0. Additional Features are given as annexes; none of the Additional Features are at a TC39-proposal stage. See <a href=https://github.com/js-choi/proposal-smart-pipelines/blob/master/readme.md>the proposal's explainer</a> for the proposal's background, motivation, usage examples, explanation, and information on planned add-on proposals.</p>
</emu-intro>
<emu-clause id=executable-code-and-execution-contexts>
<h1>Executable Code and Execution Contexts</h1>
<emu-clause id=sec-lexical-environments>
<h1>Lexical Environments</h1>
<emu-clause id=sec-lexical-topics>
<h1><ins>Lexical Topics</ins></h1>
<emu-note type=editor>
<p>This section is a wholly new sub-clause of the <a href=https://tc39.github.io/ecma262/#sec-lexical-environments>original Lexical Environments clause</a>. It is forward compatible with <emu-xref href=#sec-additional-feature-np-lexical-environments>further modifications by Additional Feature NP</emu-xref>.</p>
</emu-note>
<p>The <dfn>topic binding</dfn> of a Lexical Environment immutably binds the topic reference `#` to one value of any ECMAScript language type (called the <dfn>topic value</dfn> or simply the <dfn>topic</dfn>), within that Lexical Environment, at the time of the Lexical Environment's instantiation. The topic of a Lexical Environment conceptually serves as the value that the lexical context is "about".</p>
<p>A <dfn>topic-binding environment</dfn> is a Lexical Environment that establishes a topic binding. The <dfn>topic environment</dfn> of the running execution context is its Lexical Environment's nearest outer environment that is a topic-binding environment, as defined by the abstract operator GetTopicEnvironment.</p>
<emu-note>
<p>The <strong>only</strong> Lexical Environments that are topic-binding environments are declarative environments that are associated with <strong>|PipelineTopicStep|</strong> and which were created with the <strong>TopicEnvironmentInstantiation</strong> abstract operation.</p>
<p>There is also one syntax nonterminal that <strong>instantiates</strong> topic-binding environments with <strong>provided topic values</strong> of any ECMAScript language type. This <dfn>topic-binding nonterminal</dfn> is |ConditionalExpression| in <emu-grammar>PipelineTopicStep : ConditionalExpression</emu-grammar>, which may use the abstract operation <strong>TopicEnvironmentInstantiation</strong>. In addition, |PipelineTopicStep| <strong>hides</strong> its own inner topic references from Contains. Within the scope of <emu-grammar>PipelineTopicStep : ConditionalExpression</emu-grammar>, such topic references would <strong>not</strong> trigger early error rules during program compilation. Instead, they would be evaluated at runtime into the values of the <strong>newly instantiated</strong> topic-binding environments' topic bindings.</p>
<p>All other Lexical Environments do not establish any topic bindings; in particular, object and global environments are never topic-binding environments.</p>
<p>In addition, several syntax nonterminals associated with Lexical Environments are associated with early error rules that <strong>forbid</strong> their containing the topic reference `#`, <strong>except</strong> where the topic reference is within <emu-grammar>PipelineTopicStep : ConditionalExpression</emu-grammar>. These <dfn>topic-forbidding nonterminals</dfn> are:</p>
<dl>
<dt><strong>Top-level program scopes</strong>:</dt>
<dd>|ScriptBody| from <emu-grammar>Script : ScriptBody</emu-grammar>.</dd>
<dd>|ModuleBody| from <emu-grammar>Module : ModuleBody</emu-grammar>.</dd>
<dt><strong>Inner program scopes</strong> that <strong>establish lexical bindings</strong>:</dt>
<dd>Any |FunctionStatementList| from <emu-grammar>FunctionBody : FunctionStatementList</emu-grammar>, <strong>except</strong> when |FunctionStatementList| is the |FunctionBody| of a |ConciseBody|—that is, <strong>except</strong> when it is the body of an |ArrowFunction|.</dd>
<dd>Any |Statement| in any production of |IterationStatement|, such as |Statement| from <emu-grammar>|IterationStatement| : `for` `(` ForDeclaration `in` Expression `)` Statement</emu-grammar>.</dd>
<dd>Any |Statement| from <emu-grammar>WithStatement : `with` `(` Expression `)` Statement</emu-grammar>.</dd>
<dd>Any |Block| from <emu-grammar>Catch : `catch` `(` CatchParameter `)` Block</emu-grammar>.</dd>
</dl>
<p>Any use of the topic reference within these nonterminals (as detected by the static semantic rule <strong>Contains</strong>) would trigger <strong>early error rules</strong> associated with their productions: during program compilation, <strong>before</strong> runtime evaluation ever would have begun.</p>
<p>Also note that the other nonterminals of the productions above do not have similar topic-forbidding early error rules. For instance, the topic reference may be used as usual within |ForDeclaration| from <emu-grammar>ForStatement : `for` `(` ForDeclaration `in` Expression `)`</emu-grammar>.</p>
<p>Other syntax nonterminals, even if they similarly define inner program scopes that contain nested |Statement|s, <strong>may</strong> contain topic references, as long as there is a topic binding in the outer scope. These other nonterminals have no early error rules that check for topic references. <strong>Topic-permitting</strong> nonterminals include:</p>
<dt><strong>Topic-permitting inner program scopes</strong>:</dt>
<dd>Any |FunctionStatementList| from <emu-grammar>FunctionBody : FunctionStatementList</emu-grammar> <strong>only</strong> in which |FunctionStatementList| is the |FunctionBody| of a <strong>|ConciseBody|</strong>—that is, the body of an <strong>|ArrowFunction|</strong>.</dd>
<dd>Any |Statement| in any production of |IfStatement|, such as <emu-grammar>`if` `(` Expression `)` Statement</emu-grammar>.</dd>
<dd>Any |CaseBlock| from <emu-grammar>SwitchStatement : `switch` `(` Expression `)` CaseBlock</emu-grammar>.</dd>
<dd>Any |Block| from <emu-grammar>TryStatement : `try` Block Catch</emu-grammar>, but not |Catch| itself, which forbids topic references.</dd>
<dd>Any |Block| from <emu-grammar>Finally : `finally` Block</emu-grammar>.</dd>
<dd>Any |Block| from <emu-grammar>BlockStatement : Block</emu-grammar>.</dd>
</dl>
<p>These topic-permitting nonterminals’ Lexical Environments do <strong>not</strong> establish topic bindings of their own; therefore, at runtime, topic references that are contained within their scopes would be <strong>evaluated</strong> to the value of their <strong>outer</strong> environments' topic bindings. In addition, their inner topic references are <strong>visible</strong> to Contains and they are subject to the same early error rules associated with their <strong>outer</strong> scopes’ productions.</p>
</emu-note>
</emu-clause>
<emu-clause id=sec-environment-records>
<h1>Environment Records</h1>
<emu-note type=editor>
<p>This section augments the <a href=https://tc39.github.io/ecma262/#sec-environment-records>original Environment Records clause</a>. It is forward compatible with <emu-xref href=#sec-additional-feature-np-environment-records>further modifications by Additional Feature NP</emu-xref>.</p>
</emu-note>
<emu-table id=table-15 caption="Abstract Methods of Environment Records">
<table>
<thead>
<tr>
<th>
Method
</th>
<th>
Purpose
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<ins>HasTopicBinding()</ins>
</td>
<td>
<ins>Determine the status of an Environment Record's topic binding. Return *true* if it establishes a topic binding and *false* if it does not.</ins>
</td>
</tr>
</tbody>
</table>
</emu-table>
<emu-clause id=sec-declarative-environment-records>
<h1>Declarative Environment Records</h1>
<emu-note type=editor>
<p>This section augments the <a href=https://tc39.github.io/ecma262/#sec-declarative-environment-records>original Declarative Environment Records clause</a>. It is forward compatible with <emu-xref href=#sec-additional-feature-np-declarative-environment-records>further modifications by Additional Feature NP</emu-xref>.</p>
</emu-note>
<p>Each declarative Environment Record is associated with an ECMAScript program scope containing variable, constant, let, class, module, import, and/or function declarations. A declarative Environment Record binds the set of identifiers defined by the declarations contained within its scope.</p>
<ins class=block>
<p>Declarative Environment Records have the additional state fields listed in <emu-xref href="#table-61"></emu-xref>.</p>
<emu-table id=table-61 caption="Additional Fields of Declarative Environment Records">
<table>
<thead>
<tr>
<th>
Method
</th>
<th>
Value
</th>
<th>
Purpose
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
[[TopicBindingStatus]]
</td>
<td>
*false* | *true*
</td>
<td>
If [[TopicBindingStatus]]'s value is *true*, the Environment Record binds the Environment Record establishes its environment's topic binding (that is, it binds `#`) to values. If the value is *false*, the Environment Record has no topic binding. [[TopicBindingStatus]]'s default value is *false*. Its value may be changed from *false* to *true* but never vice versa.
</td>
</tr>
<tr>
<td>
[[TopicValues]]
</td>
<td>
List of any | ~empty~
</td>
<td>
If the value of [[TopicBindingStatus]] is *true*, [[TopicValues]] is a List containing the one element which is the environment's topic value (that is, the value of `#` within its program scope). Otherwise, the value of [[TopicValues]] is ~empty~.
</td>
</tr>
</tbody>
</table>
</emu-table>
<emu-note type=editor>
<p>[[TopicValues]] is a List in order to be <emu-xref href=#sec-additional-feature-np-declarative-environment-records>forward compatible with Additional Feature NP</emu-xref>.</p>
</emu-note>
<p>Declarative Environment Records support all of the abstract methods of Environment Records listed in <emu-xref href="#table-15"></emu-xref>. In addition, declarative Environment Records support the methods listed in <emu-xref href="#table-62"></emu-xref>.</p>
<emu-table id=table-62 caption="Additional Methods of Declarative Environment Records">
<table>
<thead>
<tr>
<th>
Method
</th>
<th>
Purpose
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
BindTopicValues(V)
</td>
<td>
Establish the immutable topic binding of this Environment Record and set the topic binding's value. _V_ is a List containing the one element which is the topic value and is a value of any ECMAScript language type. Afterward, the value returned by the Environment Record's HasTopicBinding method is *true*. This method cannot be called more than once on any single Environment Record.
</td>
</tr>
</tbody>
</table>
</emu-table>
</ins>
<emu-note type=editor>
<p>BindTopicValues() accepts a List argument rather than a single-value argument in order to be <emu-xref href=#sec-additional-feature-np-declarative-environment-records>forward compatible with Additional Feature NP</emu-xref>.</p>
</emu-note>
<p>The behaviour of the concrete <ins>and additional</ins> specification methods for declarative Environment Records is defined by the following algorithms.</p>
<emu-clause id=sec-declarative-environment-records-hastopicbinding>
<h1><ins>HasTopicBinding ( )</ins></h1>
<emu-note type=editor>
<p>This section is a wholly new sub-clause of the <a href=https://tc39.github.io/ecma262/#sec-declarative-environment-records>original Declarative Environment Records clause</a>.</p>
</emu-note>
<p>The concrete Environment Record method HasTopicBinding for declarative Environment Records returns the value of the record's field [[TopicBindingStatus]], which is *false* by default. The value may instead be *true* if its BindTopicValues method has been called.</p>
<emu-alg>
1. Let _envRec_ be the function Environment Record for which the method was invoked.
2. Return _envRec_.[[TopicBindingStatus]].
</emu-alg>
</emu-clause>
<emu-clause id=sec-declarative-environment-records-bindtopicvalues>
<h1><ins>BindTopicValues ( _V_ )</ins></h1>
<emu-note type=editor>
<p>This section is a wholly new sub-clause of the <a href=https://tc39.github.io/ecma262/#sec-declarative-environment-records>original Declarative Environment Records clause</a>. It is forward compatible with <emu-xref href=#sec-additional-feature-np-declarative-environment-records-bindtopicvalues>further modifications by Additional Feature NP</emu-xref>.</p>
</emu-note>
<p>The method BindTopicValues for declarative Environment Records is guaranteed to be called only when the Environment Records do not yet have established topic bindings.</p>
<emu-alg>
1. <ins>Assert: _V_ is a List.</ins>
2. Let _envRec_ be the declarative Environment Record for which the method was invoked.
3. Assert: _envRec_.[[TopicBindingStatus]] is *false*.
4. Set _envRec_.[[TopicValues]] to _V_.
5. Set _envRec_.[[TopicBindingStatus]] to *true*.
6. Return NormalCompletion(~empty~).
</emu-alg>
</emu-clause>
</emu-clause>
<emu-clause id=sec-object-environment-records>
<h1>Object Environment Records</h1>
<emu-clause id=sec-object-environment-records-hastopicbinding>
<h1><ins>HasTopicBinding ( )</ins></h1>
<emu-note type=editor>
<p>This section is a wholly new sub-clause of the <a href=https://tc39.github.io/ecma262/#sec-object-environment-records>original Object Environment Records clause</a>.</p>
</emu-note>
<p>Regular object Environment Records never have topic bindings.</p>
<emu-alg>
1. Return *false*.
</emu-alg>
</emu-clause>
</emu-clause>
<emu-clause id=sec-global-environment-records>
<h1>Global Environment Records</h1>
<emu-clause id=sec-global-environment-records-hastopicbinding>
<h1><ins>HasTopicBinding ( )</ins></h1>
<emu-note type=editor>
<p>This section is a wholly new sub-clause of the <a href=https://tc39.github.io/ecma262/#sec-object-environment-records>original Global Environment Records clause</a>.</p>
</emu-note>
<p>Global Environment Records never have topic bindings.</p>
<emu-alg>
1. Return *false*.
</emu-alg>
</emu-clause>
</emu-clause>
</emu-clause>
</emu-clause>
</emu-clause>
<emu-clause id=sec-ecmascript-language-lexical-grammar>
<h1>ECMAScript Language: Lexical Grammar</h1>
<emu-clause id=sec-punctuators>
<h1>Punctuators</h1>
<emu-note type=editor>
<p>This section augments the <a href=https://tc39.github.io/ecma262/#sec-punctuators>original Punctuators clause</a>. It is forward compatible with <emu-xref href=#sec-additional-feature-np-punctuators>further modifications by Additional Feature NP</emu-xref>.</p>
</emu-note>
<ins class=block>
<emu-grammar>
Punctuator :: one of
`{` `(` `)` `[` `]` `.` `...` `;` `,` `<` `>` `<=` `>=` `==` `!=` `===` `!==` `+` `-` `*` `%` `**` `++` `--` `<<` `>>` `>>>` `&` `|` `^` `!` `~` `&&` `||` `?` `:` `|>` `#` `=` `+=` `-=` `*=` `%=` `**=` `<<=` `>>=` `>>>=` `&=` `|=` `^=` `=>`
</emu-grammar>
</ins>
<del class=block>
<emu-grammar>
Punctuator :: one of
`{` `(` `)` `[` `]` `.` `...` `;` `,` `<` `>` `<=` `>=` `==` `!=` `===` `!==` `+` `-` `*` `%` `**` `++` `--` `<<` `>>` `>>>` `&` `|` `^` `!` `~` `&&` `||` `?` `:` `=` `+=` `-=` `*=` `%=` `**=` `<<=` `>>=` `>>>=` `&=` `|=` `^=` `=>`
</emu-grammar>
</del>
</emu-clause>
</emu-clause>
<emu-clause id=sec-ecmascript-language-expressions>
<h1>ECMAScript Language: Expressions</h1>
<emu-clause id=sec-primary-expression>
<h1>Primary Expression</h1>
<emu-note type=editor>
<p>This section augments the <a href=https://tc39.github.io/ecma262/#sec-primary-expression>original Primary Expression clause</a>. It is forward compatible with <emu-xref href=#sec-additional-feature-np-primary-expression>further modifications by Additional Feature NP</emu-xref>.</p>
</emu-note>
<h2>Syntax</h2>
<emu-grammar>
PrimaryExpression[Yield, Await] :
`this`
<ins>`#`</ins>
IdentifierReference[?Yield, ?Await]
Literal
ArrayLiteral[?Yield, ?Await]
ObjectLiteral[?Yield, ?Await]
FunctionExpression
ClassExpression[?Yield, ?Await]
GeneratorExpression
AsyncFunctionExpression
AsyncGeneratorExpression
RegularExpressionLiteral
TemplateLiteral[?Yield, ?Await, ~Tagged]
CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await]
</emu-grammar>
<emu-clause id=sec-topic-references>
<h1>The <ins>Topic Reference</ins></h1>
<emu-note type=editor>
<p>This section is a wholly new sub-clause to be inserted between the <a href=https://tc39.github.io/ecma262/#sec-this-keyword>original `this` Keyword clause</a> and the <a href=https://tc39.github.io/ecma262/#sec-identifier-reference>original Identifier Reference clause</a>. It is forward compatible with <emu-xref href=#sec-additional-feature-np-topic-references>further modifications by Additional Feature NP</emu-xref>.</p>
</emu-note>
<emu-note>
<p>The <dfn>topic reference</dfn>, which is the token `#`, is a nullary operator that evaluates to the value of the current Lexical Environment's topic. The topic reference acts as if it were a special variable: implicitly bound to the topic value, yet still lexically scoped. But `#` is not actually an |IdentifierName| and the topic reference is not a variable, and it cannot be bound by typical assignment; instead, it is immutably bound to a value during the instantiation of certain topic-binding environments.</p>
<p>The concept of lexical topic binding is further discussed in <emu-xref href="#sec-lexical-topics">Lexical Topics</emu-xref> and in <emu-xref href="#sec-declarative-environment-records">Declarative Environment Records</emu-xref>.</p>
</emu-note>
<emu-clause id=sec-gettopicenvironment aoid=GetTopicEnvironment>
<h1>Runtime Semantics: GetTopicEnvironment</h1>
<emu-note>
<p>GetTopicEnvironment finds the Environment Record that currently supplies the topic binding (the binding of `#`). That is, it finds the running execution topic's nearest-ancestral topic-binding environment, which is the nearest-ancestral outer environment that has a topic binding status of *true*. It is <strong>never</strong> called when there is no topic environment.</p>
</emu-note>
<p>When the abstract operation GetTopicEnvironment is called the following steps are performed:</p>
<emu-alg>
1. Let _lex_ be the running execution context's Lexical Environment.
2. Repeat,
1. Let _envRec_ be _lex_'s Environment Record.
2. Let _status_ be _envRec_.HasTopicBinding().
3. If _status_ is *true*, return _envRec_.
4. Assert: _lex_ is not a global environment.
4. Let _outer_ be the value of _lex_'s outer environment reference.
6. Set _lex_ to _outer_.
3. Return _lex_.
</emu-alg>
<emu-note>
<p>The loop in step 2 will always terminate because the List of environments will always end before reaching the global environment. GetTopicEnvironment will never be called when there is no topic-binding environment in the List of environments.</p>
<p>This is because how, in general, syntax nonterminals that define top-level scopes (such as |Script| and |Module|) are syntactically forbidden to contain the topic reference `#`. Any use of the topic reference within those nonterminals (as detected by the static semantic rule Contains) would trigger early error rules associated with those nonterminals. It is only within nonterminals that hide the topic reference from Contains such as |ConditionalExpression| in <emu-grammar>PipelineTopicStep : ConditionalExpression</emu-grammar> that the topic reference is syntactically permitted.</p>
</emu-note>
</emu-clause>
<emu-clause id=sec-gettopicvalues aoid=GetTopicValues>
<h1>Runtime Semantics: GetTopicValues</h1>
<emu-note>
<p>GetTopicValues gets the values of the topic environment’s current topic binding. It is <strong>never</strong> called when there is no topic environment.</p>
</emu-note>
<p>When the abstract operation GetTopicEnvironment is called the following steps are performed:</p>
<emu-alg>
1. Let _envRec_ be GetTopicEnvironment().
2. Assert: _envRec_ is a declarative Environment Record.
3. Assert: _envRec_.HasTopicBinding() is true.
4. Let _topicValues_ be _envRec_.[[TopicValues]].
5. Assert: _topicValues_ has at least one element.
6. Return topicValues.
</emu-alg>
</emu-clause>
<emu-clause id=sec-topic-references-runtime-semantics-evaluation>
<h1>Runtime Semantics: Evaluation</h1>
<emu-grammar>PrimaryExpression : `#`</emu-grammar>
<emu-alg>
1. Let _topicValues_ be GetTopicValues().
2. Return topicValues_[0].
</emu-alg>
</emu-clause>
</emu-clause>
<emu-clause id="sec-function-calls">
<h1>Function Calls</h1>
<emu-clause id="sec-evaluatecall" aoid="EvaluateCall" oldids="sec-evaluatedirectcall">
<h1>Runtime Semantics: EvaluateCall(_func_, _ref_, _arguments_, _tailPosition_ )</h1>
<emu-note type=editor>
<p>This section is an augmentation of the <a href=https://tc39.github.io/ecma262/#sec-evaluatecall>original EvaluateCall clause</a> such that its _arguments_ parameter may be a List, rather than a Parse Node that will undergo ArgumentListEvaluation into a List.</p>
</emu-note>
<p>The abstract operation EvaluateCall takes as arguments a value _func_, a value _ref_, a Parse Node <ins>or List</ins> _arguments_, and a Boolean argument _tailPosition_. It performs the following steps:</p>
<emu-alg>
1. <ins>Assert: _arguments_ is either a Parse Node or a List.</ins>
1. If Type(_ref_) is Reference, then
1. If IsPropertyReference(_ref_) is *true*, then
1. Let _thisValue_ be GetThisValue(_ref_).
1. Else the base of _ref_ is an Environment Record,
1. Let _refEnv_ be GetBase(_ref_).
1. Let _thisValue_ be _refEnv_.WithBaseObject().
1. Else Type(_ref_) is not Reference,
1. Let _thisValue_ be *undefined*.
1. <ins>If _arguments_ is a List, let _argList_ be _arguments_.</ins>
1. <ins>Else l</ins><del>L</del>et _argList_ be ArgumentListEvaluation of _arguments_.
1. ReturnIfAbrupt(_argList_).
1. If Type(_func_) is not Object, throw a *TypeError* exception.
1. If IsCallable(_func_) is *false*, throw a *TypeError* exception.
1. If _tailPosition_ is *true*, perform PrepareForTailCall().
1. Let _result_ be Call(_func_, _thisValue_, _argList_).
1. Assert: If _tailPosition_ is *true*, the above call will not return here, but instead evaluation will continue as if the following return has already occurred.
1. Assert: If _result_ is not an abrupt completion, then Type(_result_) is an ECMAScript language type.
1. Return _result_.
</emu-alg>
</emu-clause>
</emu-clause>
</emu-clause>
<emu-clause id=sec-pipe-operator>
<h1><ins>Pipe Operator</ins></h1>
<emu-note type=editor>
<p>This section is a wholly new sub-clause to be inserted between the <a href=https://tc39.github.io/ecma262/#sec-conditional-operator>original Conditional Operator (`?` `:`) clause</a> and the <a href=https://tc39.github.io/ecma262/#sec-assignment-operators>original Assignment Operators clause</a>. It is forward compatible with <emu-xref href=#sec-additional-feature-bp-pipe-operator>further modifications by Additional Feature BP</emu-xref> and <emu-xref href=#sec-additional-feature-np-pipe-operator>further modifications by Additional Feature NP</emu-xref>.</p>
</emu-note>
<h2>Syntax</h2>
<emu-grammar type=definition>
PipeExpression[In, Yield, Await] :
ConditionalExpression[?In, ?Yield, ?Await]
ConditionalExpression[?In, ?Yield, ?Await] `|>` Pipeline[?In, ?Yield, ?Await]
Pipeline[In, Yield, Await] :
CoverPipelineBareStepAndTopicStep[?In, ?Yield, ?Await]
CoverPipelineBareStepAndTopicStep[?In, ?Yield, ?Await] `|>` Pipeline[?In, ?Yield, ?Await]
CoverPipelineBareStepAndTopicStep[In, Yield, Await] :
ConditionalExpression[?In, ?Yield, ?Await]
</emu-grammar>
<h2>Supplemental Syntax</h2>
<p>When processing an instance of the production <emu-grammar>CoverPipelineBareStepAndTopicStep : ConditionalExpression</emu-grammar>, the interpretation of |ConditionalExpression| is refined using the following grammar:</p>
<emu-grammar type=definition>
PipelineBareStep :
SimpleReference
SimpleReference :
IdentifierReference
SimpleReference `.` IdentifierName
PipelineTopicStep[In, Yield, Await] :
[lookahead <! {`{`}] ConditionalExpression[?In, ?Yield, ?Await]
</emu-grammar>
<emu-clause id=sec-pipe-operator-static-semantics-early-errors>
<h1>Static Semantics: Early Errors</h1>
<emu-note type=editor>
<p>This section is a wholly new sub-clause. It is forward compatible with <emu-xref href=#sec-additional-feature-np-pipe-operator-static-semantics-early-errors>further modifications by Additional Feature NP</emu-xref>.</p>
</emu-note>
<emu-grammar>PipeExpression : ConditionalExpression `|>` Pipeline</emu-grammar>
<emu-grammar>PipelineTopicStep : ConditionalExpression</emu-grammar>
<emu-alg>
1. It is a Syntax Error if _ConditionalExpression_ is covering |Arguments|.
</emu-alg>
<emu-note type=editor>
<p>These early errors prohibit any pipeline input expressions or pipeline step expressions from covering comma-separated argument lists. This in turn ensures forward compatibility with <emu-xref href=#sec-additional-feature-np-pipe-operator>further modifications by Additional Feature NP</emu-xref>.</p>
</emu-note>
<emu-grammar>PipelineTopicStep : ConditionalExpression</emu-grammar>
<emu-alg>
1. It is a Syntax Error if _ConditionalExpression_ Contains `#` is *false*.
2. It is a Syntax Error if _ConditionalExpression_ is covering a |YieldExpression|.
3. It is a Syntax Error if _ConditionalExpression_ is covering a |PipelineTopicListHead|.
</emu-alg>
<emu-note type=editor>
<p>This third early error prohibits a topic-style pipeline step from covering a comma-separated expression. This in turn ensures forward compatibility with <emu-xref href=#sec-additional-feature-np-pipe-operator>further modifications by Additional Feature NP</emu-xref>.</p>
</emu-note>
</emu-clause>
<emu-clause id=sec-pipe-operator-static-semantics-contains>
<h1>Static Semantics: Contains</h1>
<p>With parameter _symbol_.</p>
<emu-see-also-para op="Contains"></emu-see-also-para>
<emu-note type=editor>
<p>This section is a wholly new sub-clause. It is forward compatible with <emu-xref href=#sec-additional-feature-np-pipe-operator-static-semantics-early-errors>further modifications by Additional Feature NP</emu-xref>.</p>
</emu-note>
<emu-grammar>PipelineTopicStep : ConditionalExpression</emu-grammar>
<emu-alg>
1. If _symbol_ is `#`, return *false*.
2. For each child node _child_ of this Parse Node, do
1. If _child_ is an instance of _symbol_, return *true*.
2. If _child_ is an instance of a nonterminal, then
1. Let _contained_ be the result of _child_ Contains _symbol_.
2. If _contained_ is *true*, return *true*.
2. Return *false*.
</emu-alg>
</emu-clause>
<emu-clause id=sec-pipe-operator-static-semantics-coveredpipelinestep>
<h1>Static Semantics: CoveredPipelineStep</h1>
<emu-note type=editor>
<p>This section is a wholly new sub-clause.</p>
</emu-note>
<emu-grammar>CoverPipelineBareStepAndTopicStep : ConditionalExpression</emu-grammar>
<emu-alg>
1. If _ConditionalExpression_ is covering a _PipelineBareStep_, return the _PipelineBareStep_ that is covered by _ConditionalExpression_.
2. Else, return the _PipelineTopicStep_ that is covered by _ConditionalExpression_.
</emu-alg>
</emu-clause>
<emu-clause id=sec-pipe-operator-static-semantics-expectedargumentcount>
<h1>Static Semantics: ExpectedArgumentCount</h1>
<emu-see-also-para op=ExpectedArgumentCount></emu-see-also-para>
<emu-note type=editor>
<p>This section is not strictly required for the core proposal, but it would be commonly used by both <emu-xref href=#sec-additional-feature-pf>Additional Feature PF</emu-xref> and <emu-xref href=#sec-additional-feature-np>Additional Feature NP</emu-xref>.</p>
</emu-note>
<emu-grammar>
PipelineBareStep : SimpleReference
</emu-grammar>
<emu-alg>
1. Return *0*.
</emu-alg>
<emu-grammar>PipelineTopicStep : ConditionalExpression</emu-grammar>
<emu-alg>
1. Return *1*.
</emu-alg>
<emu-grammar>Pipeline : CoverPipelineBareStepAndTopicStep `|>` Pipeline</emu-grammar>
<emu-alg>
1. Let _pipelineStep_ be CoveredPipelineStep of _CoverPipelineBareStepAndTopicStep_.
2. Return ExpectedArgumentCount of _pipelineStep_.
</emu-alg>
</emu-clause>
<emu-clause id=sec-pipe-operator-runtime-semantics-TopicEnvironmentInstantiation aoid=TopicEnvironmentInstantiation>
<h1>Runtime Semantics: TopicEnvironmentInstantiation</h1>
<emu-note type=editor>
<p>This section is a wholly new sub-clause. It is forward compatible with <emu-xref href=#sec-additional-feature-np-pipe-operator-static-semantics-early-errors>further modifications by Additional Feature NP</emu-xref>.</p>
</emu-note>
<emu-note>
<p>This abstract operation constructs, instantiates, then returns a new declarative Lexical Environment for a topic-style pipeline step. It creates an immutable topic binding in that declarative environment using the given _topicValues_.</p>
</emu-note>
<p>TopicPipelineInstantiation is performed as follows using arguments _env_ and _topicValues_.</p>
<ul>
<li>_env_ is the Lexical Environment in which the topic binding is to be created.</li>
<li>_topicValues_ is a List of values: _env_'s primary topic reference will be bound to the first value.</li>
</ul>
<emu-alg>
1. Assert: _topicValues_ is a List.
2. Let _envRec_ be env's Environment Record.
3. Assert: _envRec_ is a declarative Environment Record.
4. Assert: _envRec_.HasTopicBinding() is *false*.
5. Assert: _envRec_.[[TopicValues]] is ~empty~.
6. Perform ! _envRec_.BindTopicValues(_topicValues_).
</emu-alg>
</emu-clause>
<emu-clause id=sec-pipe-operator-runtime-semantics-pipelineevaluation aoid=PipelineEvaluation>
<h1>Runtime Semantics: PipelineEvaluation</h1>
<p>With parameter _inputValues_.</p>
<emu-grammar>PipelineBareFunction : SimpleReference</emu-grammar>
<emu-alg>
1. Let _memberExpr_ be the |MemberExpression| that is covered by _SimpleReference_.
2. Let _funcRef_ be the result of evaluating _memberExpr_.
3. Let _funcValue_ be ? GetValue(_ref_).
4. Let _thisCall_ be this |PipelineBareFunction|.
5. Let _tailCall_ be IsInTailPosition(_thisCall_).
6. Let _callRef_ be ? EvaluateCall(_funcValue_, _ref_, _inputValues_, _tailCall_).
7. Let _callValue_ be ? GetValue(_callRef_).
8. Return a List containing the one element which is _callValue_.
</emu-alg>
<emu-grammar>PipelineTopicStep : ConditionalExpression</emu-grammar>
<emu-alg>
1. Let _oldEnv_ be the running execution context's Lexical Environment.
2. Let _pipelineStepEnv_ be New Declarative Environment(_oldEnv_).
3. Perform TopicEnvironmentInstantiation(_inputValues_, _pipelineStepEnv_).
4. Set the running execution context's Lexical Environment to _pipelineStepEnv_.
5. Let _pipelineValue_ be the result of evaluating _ConditionalExpression_.
6. Set the running execution context's Lexical Environment to _oldEnv_.
7. Return a List containing the one element which is _pipelineValue_.
</emu-alg>
<emu-grammar>Pipeline : CoverPipelineBareStepAndTopicStep `|>` Pipeline</emu-grammar>
<emu-alg>
1. Let _pipelineStep_ be ? CoveredPipelineStep of _CoverPipelineBareStepAndTopicStep_.
2. Let _stepOutputValues_ be ? PipelineEvaluation of _pipelineStep_ with argument _inputValues_.
3. Let _pipelineRemainderOutputRef_ be ? PipelineEvaluation of _Pipeline_ with argument _stepOutputValues_.
4. Return ? GetValue(_pipelineRemainderOutputRef_).
</emu-alg>
</emu-clause>
<emu-clause id=sec-pipe-operator-runtime-semantics-evaluation>
<h1>Runtime Semantics: Evaluation</h1>
<emu-grammar>PipeExpression : ConditionalExpression `|>` Pipeline</emu-grammar>
<emu-alg>
1. Let _inputRef_ be the result of evaluating _ConditionalExpression_.
2. Let _inputValues_ be a List containing the one element which is the result of ? GetValue(_inputRef_).
3. Let _pipelineOutputValues_ be ? PipelineEvaluation of _Pipeline_ with argument _inputValues_.
4. Assert: _pipelineOutputValues_ is a List containing one element.
5. Return _pipelineOutputValues_[0].
</emu-alg>
</emu-clause>
</emu-clause>
<emu-clause id=sec-assignment-operators>
<h1>Assignment Operators</h1>
<emu-note type=editor>
<p>This section augments the <a href=https://tc39.github.io/ecma262/#sec-assignment-operators>original Assignment Operators clause</a>. It is forward compatible with <emu-xref href=#sec-additional-feature-pf-assignment-operators>further modifications by Additional Feature PF</emu-xref>.</p>
</emu-note>
<h2>Syntax</h2>
<emu-grammar>
AssignmentExpression[In, Yield, Await] :
<del>ConditionalExpression[?In, ?Yield, ?Await]</del>
<ins>PipeExpression[?In, ?Yield, ?Await]</ins>
[+Yield] YieldExpression[?In, ?Await]
ArrowFunction[?In, ?Yield, ?Await]
AsyncArrowFunction[?In, ?Yield, ?Await]
LeftHandSideExpression[?Yield, ?Await] `=` AssignmentExpression[?In, ?Yield, ?Await]
LeftHandSideExpression[?Yield, ?Await] AssignmentOperator AssignmentExpression[?In, ?Yield, ?Await]
</emu-grammar>
</emu-clause>
</emu-clause>
<emu-clause id=sec-ecmascript-language-statements-and-declarations>
<h1>ECMAScript Language: Statements and Declarations</h1>
<emu-clause id=sec-iteration-statements>
<h1>Iteration Statements</h1>
<emu-note type=editor>
<p>This section augments the <a href=https://tc39.github.io/ecma262/#sec-iteration-statements>original Iteration Statements clause</a>. It is forward compatible with <emu-xref href=#sec-additional-feature-np-iteration-statements-static-semantics-early-errors>further modifications by Additional Feature NP</emu-xref> and further modifications by Additional Feature TS.</p>
</emu-note>
<emu-clause id=sec-iteration-statements-static-semantics-early-errors>
<h1>Static Semantics: Early Errors</h1>
<emu-grammar>
IterationStatement :
`do` Statement `while` `(` Expression `)` `;`
`while` `(` Expression `)` Statement
`for` `(` Expression? `;` Expression? `;` Expression? `)` Statement
`for` `(` `var` VariableDeclarationList `;` Expression? `;` Expression? `)` Statement
`for` `(` LexicalDeclaration Expression? `;` Expression? `)` Statement
`for` `(` LeftHandSideExpression `in` Expression `)` Statement
`for` `(` `var` ForBinding `in` Expression `)` Statement
`for` `(` ForDeclaration `in` Expression `)` Statement
`for` `(` LeftHandSideExpression `of` AssignmentExpression `)` Statement
`for` `(` `var` ForBinding `of` AssignmentExpression `)` Statement
`for` `(` ForDeclaration `of` AssignmentExpression `)` Statement
`for` `await` `(` LeftHandSideExpression `of` AssignmentExpression `)` Statement
`for` `await` `(` `var` ForBinding `of` AssignmentExpression `)` Statement
`for` `await` `(` ForDeclaration `of` AssignmentExpression `)` Statement
</emu-grammar>
<ul>
<li><ins>It is a Syntax Error if |Statement| Contains `#` is *true*.</ins></li>
</ul>
<ins class=block>
<emu-note>
<p>Syntax nonterminals that establish new lexical bindings within new inner program scopes, including iteration statements, may <strong>not</strong> contain a topic reference `#`. However, such topic-forbidding nonterminals may also contain topic-binding nonterminals such as |ConditionalExpression| in <emu-grammar>PipelineTopicStep : ConditionalExpression</emu-grammar>, which would, in turn, hide their own inner topic references from the Contains abstract operation. Within those topic-binding nonterminals, such topic references would therefore not trigger the early error above.</p>
</emu-note>
</ins>
</emu-clause>
</emu-clause>
<emu-clause id=sec-with-statement>
<h1>The `with` statement</h1>
<emu-clause id=sec-with-statement-static-semantics-early-errors>
<h1>Static Semantics: Early Errors</h1>
<emu-note type=editor>
<p>This section augments the <a href=https://tc39.github.io/ecma262/#sec-with-statement-static-semantics-early-errors>original `with` Statement, Static Semantics: Early Errors clause</a>. It is forward compatible with <emu-xref href=#sec-additional-feature-np-function-definitions-static-semantics-early-errors>further modifications by Additional Feature NP</emu-xref>. It is not planned to be removed by other additional syntax.</p>
</emu-note>
<emu-grammar>WithStatement : `with` `(` Expression `)` Statement</emu-grammar>
<ul>
<li>
<ins>It is a Syntax Error if |Statement| Contains `#` is *true*.</ins>
</li>
</ul>
<ins class=block>
<emu-note>
<p>Syntax nonterminals that establish new lexical bindings within new inner program scopes, including |WithStatement|, may <strong>not</strong> contain a topic reference `#`. However, such topic-forbidding nonterminals may also contain topic-binding nonterminals such as |ConditionalExpression| in <emu-grammar>PipelineTopicStep : ConditionalExpression</emu-grammar>, which would, in turn, hide their own inner topic references from the Contains abstract operation. Within those topic-binding nonterminals, such topic references would therefore not trigger the early error above.</p>
</emu-note>
</ins>
</emu-clause>
</emu-clause>
<emu-clause id=sec-try-statement>
<h1>The `try` statement</h1>
<emu-clause id=sec-try-statement-static-semantics-early-errors>
<h1>Static Semantics: Early Errors</h1>
<emu-note type=editor>
<p>This section augments the <a href=https://tc39.github.io/ecma262/#sec-try-statement-static-semantics-early-errors>original `try` Statement, Static Semantics: Early Errors clause</a>. It is forward compatible with <emu-xref href=#sec-additional-feature-np-try-statement-static-semantics-early-errors>further modifications by Additional Feature NP</emu-xref> and further modifications by Additional Feature TS. [TODO: Add link to Additional Feature TS once it’s written.]</p>
</emu-note>
<emu-grammar>
Catch : `catch` `(` CatchParameter `)` Block
</emu-grammar>
<ul>
<li>
<ins>It is a Syntax Error if |Block| Contains `#` is *true*.</ins>
</li>
</ul>
<ins class=block>
<emu-note>
<p>Syntax nonterminals that establish new lexical bindings within new inner program scopes, including |Catch|, may <strong>not</strong> contain a topic reference `#`. However, such topic-forbidding nonterminals may also contain topic-binding nonterminals such as |ConditionalExpression| in <emu-grammar>PipelineTopicStep : ConditionalExpression</emu-grammar>, which would, in turn, hide their own inner topic references from the Contains abstract operation. Within those topic-binding nonterminals, such topic references would therefore not trigger the early errors above.</p>
<p>Furthermore, the `try` and `finally` blocks themselves (|Block| and |Finally| in |TryStatement|) <strong>may</strong> contain topic references, assuming that the |TryStatement| is contained within a parse that is also allowed to contain the topic reference. During runtime, such topic references would refer to the outer environment's topic binding. Along with arrow functions (that is, |FunctionBody| in |ConciseBody|), this behaviour is unlike that of any other syntax nonterminal containing |Statement|.</p>
</emu-note>
</ins>
</emu-clause>
</emu-clause>
</emu-clause>
<emu-clause id=sec-ecmascript-language-functions-and-classes>
<h1>ECMAScript Language: Functions and Classes</h1>
<emu-clause id=sec-function-definitions>
<h1>Function Definitions</h1>
<emu-clause id=sec-function-definitions-static-semantics-early-errors>
<h1>Static Semantics: Early Errors</h1>
<emu-note type=editor>
<p>This section augments the <a href=https://tc39.github.io/ecma262/#sec-function-definitions-static-semantics-early-errors>original Function Definitions, Static Semantics: Early Errors clause</a>. It is forward compatible with <emu-xref href=#sec-additional-feature-np-function-definitions-static-semantics-early-errors>further modifications by Additional Feature NP</emu-xref>.</p>
</emu-note>
<emu-grammar>FunctionBody : FunctionStatementList</emu-grammar>
<ul>
<li>
<ins>If |FunctionStatementList| is not the |FunctionBody| of a |ConciseBody|, it is a Syntax Error if |FunctionStatementList| Contains `#` is *true*.</ins>
</li>
</ul>
<ins class=block>
<emu-note>
<p>Arrow functions' |ConciseBody| <strong>may</strong> contain the topic reference `#`, as long as |ConciseBody| is within a parse that is also allowed to contain the topic reference. During runtime, such topic references would refer to the outer environment's topic binding. This is not true for the definitions of <strong>other</strong> types of functions, which may <strong>not</strong> contain any topic reference.</p>
<p>Along with |Block| in |TryStatement|, this behaviour is <strong>unlike</strong> that of any other syntax nonterminal containing |Statement|. Syntax nonterminals that establish new lexical bindings within new inner program scopes, including |FunctionBody|, may <strong>not</strong> contain a topic reference `#`.</p>
</emu-note>
</ins>
</emu-clause>
</emu-clause>
<emu-clause id=sec-arrow-function-definitions>
<h1>Arrow Function Definitions</h1>
<emu-clause id=sec-arrow-function-definitions-static-semantics-contains>
<h1>Static Semantics: Contains</h1>
<p>With parameter _symbol_.</p>
<emu-see-also-para op="Contains"></emu-see-also-para>
<emu-note type=editor>
<p>This section augments the <a href=https://tc39.github.io/ecma262/#sec-arrow-function-definitions-static-semantics-contains>original Arrow Functions, Static Semantics: Contains clause</a>. It is forward compatible with <emu-xref href=#sec-additional-feature-np-arrow-function-definitions-static-semantics-contains>further modifications by Additional Feature NP</emu-xref>.</p>
</emu-note>
<emu-grammar>ArrowFunction : ArrowParameters `=>` ConciseBody</emu-grammar>
<emu-alg>
1. If _symbol_ is not one of |NewTarget|, |SuperProperty|, |SuperCall|, <del>`super` or `this`</del> <ins>`super`, `this`, or `#`</ins>, return *false*.
2. If _ArrowParameters_ Contains _symbol_ is *true*, return *true*.
3. Return |ConciseBody| Contains _symbol_.
</emu-alg>
<emu-note>
Normally, Contains does not look inside most function forms. However, Contains is used to detect `new.target`, <del>`this`, and `super`</del><ins>`this`, `super`, and `#`</ins> usage within an |ArrowFunction|.
</emu-note>
</emu-clause>
</emu-clause>
</emu-clause>
<emu-clause id=sec-ecmascript-language-scripts-and-modules>
<h1>ECMAScript Language: Scripts and Modules</h1>
<emu-clause id=sec-scripts>
<h1>Scripts</h1>
<emu-clause id=sec-scripts-static-semantics-early-errors>
<h1>Static Semantics: Early Errors</h1>
<emu-note type=editor>
<p>This section augments the <a href=https://tc39.github.io/ecma262/#sec-scripts-static-semantics-early-errors>original Scripts, Static Semantics: Early Errors clause</a>. It is forward compatible with <emu-xref href=#sec-additional-feature-np-function-definitions-static-semantics-early-errors>further modifications by Additional Feature NP</emu-xref>. It is not planned to be removed by other additional syntax.</p>
</emu-note>
<emu-grammar>ScriptBody : StatementList</emu-grammar>
<ul>
<li>
<ins>It is a Syntax Error if |StatementList| Contains `#` is *true*.</ins>
</li>
</ul>
<ins class=block>
<emu-note>
<p>In general, a top-level program scope, including |Script|, may <strong>not</strong> contain a topic reference `#`. However, such topic-forbidding nonterminals may also contain topic-binding nonterminals such as |ConditionalExpression| in <emu-grammar>PipelineTopicStep : ConditionalExpression</emu-grammar>, which would, in turn, hide their own inner topic references from the Contains abstract operation. Within those topic-binding nonterminals, such topic references would therefore not trigger the early error above.</p>
</emu-note>
</ins>
</emu-clause>
</emu-clause>
<emu-clause id=sec-modules>
<h1>Modules</h1>
<emu-clause id=sec-modules-static-semantics-early-errors>
<h1>Static Semantics: Early Errors</h1>
<emu-note type=editor>
<p>This section augments the <a href=https://tc39.github.io/ecma262/#sec-scripts-static-semantics-early-errors>original Modules, Static Semantics: Early Errors clause</a>. It is forward compatible with <emu-xref href=#sec-additional-feature-np-function-definitions-static-semantics-early-errors>further modifications by Additional Feature NP</emu-xref>. It is not planned to be removed by other additional syntax.</p>
</emu-note>
<emu-grammar>ModuleItem : StatementListItem</emu-grammar>
<ul>
<li>
<ins>It is a Syntax Error if |StatementListItem| Contains `#` is *true*.</ins>
</li>
</ul>
<ins class=block>
<emu-note>
<p>In general, a top-level program scope, including |Module|, may <strong>not</strong> contain a topic reference `#`. However, such topic-forbidding nonterminals may also contain topic-binding nonterminals such as |ConditionalExpression| in <emu-grammar>PipelineTopicStep : ConditionalExpression</emu-grammar>, which would, in turn, hide their own inner topic references from the Contains abstract operation. Within those topic-binding nonterminals, such topic references would therefore not trigger the early error above.</p>
</emu-note>
</ins>
</emu-clause>
</emu-clause>
</emu-clause>
<emu-annex id=sec-additional-feature-bc>
<h1>Additional Feature BC: Bare Constructor Calls</h1>
<p><strong>Not at Stage 0.</strong></p>
<p>This annex specifies additional ECMAScript language syntax and semantics for <strong>bare constructor calls</strong>. It augments the <emu-xref href=#introduction>core proposal</emu-xref> by introducing an additional <strong>bare-style pipeline form</strong>, in which a |SimpleReference| is prepended with an `new`.</p>
<p>See the <a href=https://github.com/js-choi/proposal-smart-pipelines/blob/master/readme.md#additional-feature-bc>explainer document, § Motivation, Additional Feature BC</a> for information on this feature's motivation.</p>
<emu-annex id=sec-additional-feature-bc-ecmascript-language-expressions>
<h1>ECMAScript Language: Expressions</h1>
<emu-annex id=sec-additional-feature-bc-primary-expression>
<h1>Primary Expression</h1>
<emu-annex id="sec-new-operator">
<h1>The `new` Operator</h1>
<emu-annex id="sec-new-operator-runtime-semantics-evaluation">
<h1>Runtime Semantics: Evaluation</h1>
<emu-annex id="sec-evaluatenew" aoid="EvaluateNew">
<h1>Runtime Semantics: EvaluateNew ( _constructExpr_, _arguments_ )</h1>
<emu-note type=editor>
<p>This section is an augmentation of the <a href=https://tc39.github.io/ecma262/#sec-evaluatenew>original EvaluateNew clause</a> such that its _arguments_ parameter may be a List, rather than a Parse Node that will undergo ArgumentListEvaluation into a List.</p>
</emu-note>
<p>The abstract operation EvaluateNew with arguments _constructExpr_, and _arguments_ performs the following steps:</p>
<emu-alg>
1. Assert: _constructExpr_ is either a |NewExpression| or a |MemberExpression|.
1. Assert: _arguments_ is either ~empty~, a List, or an |Arguments|.
1. Let _ref_ be the result of evaluating _constructExpr_.
1. Let _constructor_ be ? GetValue(_ref_).
1. If _arguments_ is ~empty~, let _argList_ be a new empty List.
1. <ins>Else if _arguments_ is a List, let _argList_ be _arguments_.</ins>
1. Else,
1. Let _argList_ be ArgumentListEvaluation of _arguments_.
1. ReturnIfAbrupt(_argList_).
1. If IsConstructor(_constructor_) is *false*, throw a *TypeError* exception.
1. Return ? Construct(_constructor_, _argList_).
</emu-alg>
</emu-annex>
</emu-annex>
</emu-annex>
</emu-annex>
<emu-annex id=sec-additional-feature-bc-pipe-operator>
<h1>Pipe Operator</h1>
<emu-note type=editor>
<p>This section augments the <emu-xref href=#sec-pipe-operator>new clause in the core proposal</emu-xref>. It is mutually compatible with <emu-xref href=#sec-additional-feature-np-pipe-operator>further modifications by Additional Feature NP</emu-xref>.</p>
</emu-note>
<h2>Supplemental Syntax</h2>
<emu-grammar type=definition>
PipelineBareStep :
SimpleReference
<ins class=block>
`new` SimpleReference
</ins>
</emu-grammar>
<emu-annex id=sec-additional-feature-bc-pipe-operator-static-semantics-expectedargumentcount>
<h1>Static Semantics: ExpectedArgumentCount</h1>
<emu-see-also-para op=ExpectedArgumentCount></emu-see-also-para>
<emu-note type=editor>
<p>This section augments the <emu-xref href=#sec-pipe-operator-static-semantics-expectedargumentcount>new clause in the core proposal</emu-xref>. It is mutually compatible with further modifications by other additional features.</p>
</emu-note>
<emu-grammar>
PipelineBareStep :
SimpleReference
<ins class=block>
`new` SimpleReference
</ins>
</emu-grammar>
<emu-alg>
1. Return *0*.
</emu-alg>
</emu-annex>
<emu-annex id=sec-additional-feature-bc-pipe-operator-runtime-semantics-pipelineevaluation aoid=PipelineEvaluation>
<h1>Runtime Semantics: PipelineEvaluation</h1>
<p>With parameter _inputValues_.</p>
<emu-note type=editor>
<p>This section augments the <emu-xref href=#sec-pipe-operator-runtime-semantics-pipelineevaluation>new clause in the core proposal</emu-xref>.</p>
</emu-note>
<ins class=block>
<emu-grammar>PipelineBareStep : `new` SimpleReference</emu-grammar>
<emu-alg>
1. Let _constructExpr_ be the |MemberExpression| that is covered by _SimpleReference_.
2. Let _newRef_ be ? EvaluateNew(NewExpression, _inputValues_).
3. Let _newValue_ be ? GetValue(_newRef_).
4. Return a List containing the one element which is _newValue_.
</emu-alg>
</ins>
</emu-annex>
</emu-annex>
</emu-annex>
</emu-annex>
<emu-annex id=sec-additional-feature-ba>
<h1>Additional Feature BA: Bare Awaited Calls</h1>
<p><strong>Not at Stage 0.</strong></p>
<p>This annex specifies additional ECMAScript language syntax and semantics for <strong>bare awaited function calls</strong>. It augments the <emu-xref href=#introduction>core proposal</emu-xref> by introducing an additional <strong>bare-style pipeline form</strong>, in which a |SimpleReference| is prepended with an `await`.</p>
<p>See the <a href=https://github.com/js-choi/proposal-smart-pipelines/blob/master/readme.md#additional-feature-ba>explainer document, § Motivation, Additional Feature BA</a> for information on this feature's motivation.</p>
<emu-annex id=sec-additional-feature-ba-ecmascript-language-expressions>
<h1>ECMAScript Language: Expressions</h1>
<emu-annex id=sec-additional-feature-ba-pipe-operator>
<h1>Pipe Operator</h1>
<emu-note type=editor>
<p>This section augments the <emu-xref href=#sec-pipe-operator>new clause in the core proposal</emu-xref>. It is mutually compatible with <emu-xref href=#sec-additional-feature-np-pipe-operator>further modifications by Additional Feature NP</emu-xref>.</p>
</emu-note>
<h2>Supplemental Syntax</h2>
<emu-grammar type=definition>
<ins class=block>
PipelineBareAwaitedFunction[Await] :
[+Await] `await` SimpleReference
</ins>
</emu-grammar>
<emu-annex id=sec-additional-feature-ba-pipe-operator-static-semantics-expectedargumentcount>
<h1>Static Semantics: ExpectedArgumentCount</h1>
<emu-see-also-para op=ExpectedArgumentCount></emu-see-also-para>
<emu-note type=editor>
<p>This section augments the <emu-xref href=#sec-pipe-operator-static-semantics-expectedargumentcount>new clause in the core proposal</emu-xref>. It is mutually compatible with further modifications by other additional features.</p>
</emu-note>
<emu-grammar>
PipelineBareStep :