forked from tc39/proposal-private-methods
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspec.html
1174 lines (1061 loc) · 55.3 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
<!doctype html>
<meta charset="utf8">
<pre class=metadata>
title: Integrated public and private fields and methods proposal
stage: 2
contributors: Daniel Ehrenberg, Jeff Morrison, Kevin Smith, Kevin Gibbons
</pre>
<style>
emu-example figure {
align-items: initial;
width: 100%;
}
emu-note {
display: block;
border-left-color: #474747;
}
emu-note span.note {
display: inline-block;
color: #fff;
background-color: #474747;
width: initial;
padding-right: 50px;
}
emu-note div.note-contents {
padding-left: 5px;
}
emu-note[type=editor] {
border-left-color: #900;
}
emu-note[type=editor] span.note {
background-color: #900;
}
emu-example {
border-left: 5px solid #006387;
margin: 1em 0;
}
emu-example figure figcaption:first-child {
display: inline-block;
color: #fff;
background-color: #006387;
margin: 0;
padding: 0 50px 0 5px;
font-weight: normal;
text-transform: uppercase;
margin-left: -5px;
}
emu-example figure figcaption:nth-child(2) {
margin: 0;
padding: 0;
padding-left: 5px;
margin-left: -5px;
font-size: 20px;
font-weight: bold;
margin-bottom: 10px;
}
emu-example p:nth-of-type(1) {
margin-top: 0;
}
emu-example figure {
padding-left: 5px;
display: block;
margin: 0;
}
emu-example pre {
margin: 0;
}
</style>
<emu-intro id=sec-intro>
<h1>Introduction</h1>
<p>This document attempts to integrate the <a href="https://tc39.github.io/proposal-class-public-fields">public fields</a> and <a href="https://tc39.github.io/proposal-private-fields">private fields</a> proposals into a single, coherent, orthogonal whole. See <a href="https://github.com/littledan/proposal-class-fields">the explainer</a> for an overview.</p>
</emu-intro>
<emu-clause id=sec-syntax>
<h1>Syntax</h1>
<emu-clause id=sec-new-syntax>
<h1>New Productions</h1>
<emu-grammar>
ClassElementName[Yield, Await] :
PropertyName[?Yield, ?Await]
PrivateName
FieldDefinition[Yield, Await] :
ClassElementName[?Yield, ?Await] Initializer[In, ?Yield]?
FieldDefinitionList[Yield, Await] :
FieldDefinition[?Yield, ?Await]
FieldDefinitionList[?Yield, ?Await] `,` FieldDefinition[?Yield, ?Await]
PrivateName ::
`#` IdentifierName
</emu-grammar>
</emu-clause>
<emu-clause id=sec-updated-syntax>
<h1>Updated Productions</h1>
<emu-grammar>
ClassElement[Yield, Await] :
MethodDefinition[?Yield, ?Await]
`static` MethodDefinition[?Yield, ?Await]
<ins>FieldDefinitionList[?Yield, ?Await] `;`</ins>
<ins>`static` FieldDefinitionList[?Yield, ?Await] `;`</ins>
`;`
MemberExpression[Yield, Await] :
PrimaryExpression[?Yield, ?Await]
MemberExpression[?Yield, ?Await] `[` Expression[+In, ?Yield, ?Await] `]`
MemberExpression[?Yield, ?Await] `.` IdentifierName
MemberExpression[?Yield, ?Await] TemplateLiteral[?Yield, ?Await]
SuperProperty[?Yield, ?Await]
MetaProperty
`new` MemberExpression[?Yield, ?Await] Arguments[?Yield, ?Await]
<ins>MemberExpression[?Yield, ?Await] `.` PrivateName</ins>
PrimaryExpression[Yield, Await] :
`this`
IdentifierReference[?Yield, ?Await]
Literal
ArrayLiteral[?Yield, ?Await]
ObjectLiteral[?Yield, ?Await]
FunctionExpression
ClassExpression[?Yield, ?Await]
GeneratorExpression
AsyncFunctionExpression
RegularExpressionLiteral
TemplateLiteral[?Yield, ?Await]
CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await] #parencover
<ins>PrivateName</ins>
MethodDefinition[Yield, Await] :
<del>PropertyName</del><ins>ClassElementName</ins>[?Yield, ?Await] `(` UniqueFormalParameters[~Yield, ~Await] `)` `{` FunctionBody[~Yield, ~Await] `}`
GeneratorMethod[?Yield, ?Await]
AsyncMethod[?Yield, ?Await]
`get` <del>PropertyName</del><ins>ClassElementName</ins>[?Yield, ?Await] `(` `)` `{` FunctionBody[~Yield, ~Await] `}`
`set` <del>PropertyName</del><ins>ClassElementName</ins>[?Yield, ?Await] `(` PropertySetParameterList `)` `{` FunctionBody[~Yield, ~Await] `}`
GeneratorMethod[Yield, Await] :
`*` <del>PropertyName</del><ins>ClassElementName</ins>[?Yield, ?Await] `(` UniqueFormalParameters[+Yield, ~Await] `)` `{` GeneratorBody `}`
AsyncMethod[Yield, Await] :
`async` [no LineTerminator here] <del>PropertyName</del><ins>ClassElementName</ins>[?Yield, ?Await] `(` UniqueFormalParameters[~Yield, +Await] `)` `{` AsyncFunctionBody `}`
</emu-grammar>
</emu-clause>
<emu-clause id="sec-static-semantics-early-errors">
<h1>Static Semantics: Early Errors</h1>
<emu-grammar>
FieldDefinition[Yield] :
PropertyName[?Yield] Initializer?
</emu-grammar>
<ul>
<li>It is a Syntax Error if |Initializer| Contains an |IdentifierReference| whose StringValue is `"arguments"`.
</ul>
<emu-grammar>
ClassBody : ClassElementList
</emu-grammar>
<ul>
<li>It is a Syntax Error if PrivateBoundNames of |ClassBody| contains any duplicate entries, unless the name is used once for a getter and once for a setter.</li>
</ul>
<emu-grammar>ClassElement : `static` FieldDefinitionList `;`</emu-grammar>
<ul>
<li>
It is a Syntax Error if PropName of |FieldDefinitionList| includes `"prototype"`.
</li>
</ul>
<emu-note>
<p>These static rules have been modified to produce an early error if the `delete` operator is applied to a private reference.</p>
</emu-note>
<emu-grammar>UnaryExpression : `delete` UnaryExpression</emu-grammar>
<ul>
<li>
It is a Syntax Error if the |UnaryExpression| is contained in strict mode code and the derived |UnaryExpression| is <emu-grammar>PrimaryExpression : IdentifierReference</emu-grammar>, <emu-grammar>PrimaryExpression : PrivateName</emu-grammar> or <emu-grammar>MemberExpression : MemberExpression `.` PrivateName</emu-grammar>.
</li>
<li>
<p>It is a Syntax Error if the derived |UnaryExpression| is
<br>
<emu-grammar>PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList</emu-grammar>
<br>
and |CoverParenthesizedExpressionAndArrowParameterList| ultimately derives a phrase that, if used in place of |UnaryExpression|, would produce a Syntax Error according to these rules. This rule is recursively applied.</p>
</li>
</ul>
<emu-note>
<p>The last rule means that expressions such as `delete (((foo)))` produce early errors because of recursive application of the first rule.</p>
</emu-note>
<emu-note editor>Private fields may not be deleted</emu-note>
<emu-grammar>PropertyDefinition : MethodDefinition</emu-grammar>
<ul>
<li>It is a Syntax Error if PrivateBoundNames of |MethodDefinition| is non-empty</li>
</ul>
<emu-note editor>In a follow-on proposal, object literals may be permitted to have private methods, fields and accessors.</emu-note>
<emu-grammar>Script : ScriptBody?</emu-grammar>
<emu-alg>
1. Let _names_ be an empty List.
1. If |Script| is parsed directly from PerformEval,
1. Let _env_ be the running execution context's PrivateNameEnvironment.
1. Repeat while _env_ is not *null*,
1. For each binding named _N_ in _env_,
1. If _names_ does not contain _N_, append _N_ to _names_.
1. Let _env_ be _env_'s outer environment reference.
1. If AllPrivateNamesValid of |ScriptBody| with the argument _names_ is *false*, throw a SyntaxError.
</emu-alg>
<emu-grammar>Module : ModuleBody?</emu-grammar>
<ul>
<li>It is a Syntax Error if AllPrivateNamesValid of <emu-nt>ModuleBody</emu-nt> with an empty List as an argument is *false*.</li>
</ul>
<emu-note editor>References to PrivateNames which are not lexically present cause an early error. PrivateNames with or without an explicit receiver are treated identically, see <a href="https://github.com/tc39/proposal-private-fields/issues/23">bug thread</a> where a stricter policy was proposed and rejected.</emu-note>
<emu-clause id="sec-all-private-names-valid" aoid="AllPrivateNamesValid">
<h1>Static Semantics: AllPrivateNamesValid</h1>
AllPrivateNamesValid is an abstract operation which takes _names_ as an argument.
<emu-grammar>MemberExpression[Yield, Await] : MemberExpression[?Yield, ?Await] `.` PrivateName</emu-grammar>
<emu-alg>
1. If StringValue of |PrivateName| is in _names_, return *true*.
1. Return *false*.
</emu-alg>
<emu-grammar>PrimaryExpression : PrivateName</emu-grammar>
<emu-alg>
1. If StringValue of |PrivateName| is in _names_, return *true*.
1. Return *false*.
</emu-alg>
<emu-grammar> ClassBody[Yield, Await] : ClassElementList[?Yield, ?Await] </emu-grammar>
<emu-alg>
1. Let _newNames_ be the concatenation of _names_ with PrivateBoundNames of |ClassBody|.
1. Return AllPrivateNamesValid of |ClassElementList| with the argument _newNames_.
</emu-alg>
For all other grammatical productions, recurse on subexpressions/substatements, passing in the _names_ of the caller. If all pieces return *true*, then return *true*. If any returns *false*, return *false.
<emu-note editor>TODO: Elaborate the preceding paragraph with spec text inserted in each relevant place</emu-note>
</emu-clause>
<emu-clause id="sec-performeval">
<h1>Runtime Semantics: PerformEval ( _x_, _evalRealm_, _strictCaller_, _direct_ )</h1>
<emu-clause id="sec-performeval-rules-in-initializer">
<h1>Additional Early Error Rules for Eval Inside |Initializer|</h1>
<p>These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer.</p>
<emu-grammar>ScriptBody : StatementList</emu-grammar>
<ul>
<li>It is a Syntax Error if |StatementList| Contains an |IdentifierReference| whose StringValue is `"arguments"`.</li>
<li>The remaining eval rules apply as <a href="https://tc39.github.io/ecma262/#sec-performeval-rules-outside-constructors">outside a constructor</a>, <a href="https://tc39.github.io/ecma262/#sec-performeval-rules-outside-methods">inside a method</a>, and <a href="https://tc39.github.io/ecma262/#sec-performeval-rules-outside-functions">inside a function</a>.</li>
</ul>
</emu-clause>
</emu-clause>
</emu-clause>
</emu-clause>
<emu-clause id="sec-internal-algorithms">
<h1>Modified algorithms</h1>
<emu-clause id="static-semantics-propname">
<h1>Static Semantics: PropName</h1>
<emu-grammar>
FieldDefinition : ClassElementName Initializer?
</emu-grammar>
<emu-alg>
1. Return PropName of |ClassElementName|.
</emu-alg>
<emu-grammar>
ClassElementName[Yield, Await] : PropertyName[?Yield, ?Await]
</emu-grammar>
<emu-alg>
1. Return PropName of |PropertyName|.
</emu-alg>
<emu-grammar>
ClassElementName[Yield, Await] : PrivateName
</emu-grammar>
<emu-alg>
1. Return ~empty~.
</emu-alg>
</emu-clause>
<emu-clause id="sec-runtime-semantics-evaluate-name">
<h1>Runtime Semantics: Evaluation</h1>
<emu-grammar>
ClassElementName[Yield, Await] : PropertyName[?Yield, ?Await]
</emu-grammar>
<emu-alg>
1. Return the result of evaluating |PropertyName|.
</emu-alg>
<emu-grammar>
ClassElementName[Yield, Await] : PrivateName
</emu-grammar>
<emu-alg>
1. Let _bindingName_ be StringValue of |PrivateName|.
1. Let _scope_ be the running execution context's PrivateNameEnvironment.
1. Let _scopeEnvRec_ be _scope_'s EnvironmentRecord.
1. Assert: _scopeEnvRec_ has a binding for _bindingName_.
1. If _scopeEnvRec_'s binding for _bindingName_ is uninitialized,
1. Let _field_ be NewPrivateName().
1. Perform ! _scopeEnvRec_.InitializeBinding(_bindingName_, _field_).
1. Otherwise,
1. Let _field_ be _scopeEnvRec_.GetBindingValue(_bindingName_).
1. NOTE: The only case where this may occur is in getter/setter pairs; other duplicates are prohibited as a Syntax Error.
1. Return _field_.
</emu-alg>
<emu-note editor>Each time a class declaration executes, distinct internal Private Names are created. This means, that they cannot directly access each other's private state if a method of one is called with the other as a receiver.</emu-note>
</emu-clause>
<emu-clause id="runtime-semantics-class-public-field-definition-evaluation">
<h1>Runtime Semantics: EvaluateBody</h1>
<p>With parameter _functionObject_.</p>
<emu-grammar>
Initializer[In, Yield] :
`=` AssignmentExpression[?In, ?Yield]
</emu-grammar>
<emu-alg>
1. Return the result of evaluating |AssignmentExpression|.
</emu-alg>
</emu-clause>
<emu-clause id="sec-define-field">
<h1>DefineField(_receiver_, _fieldRecord_)</h1>
<emu-alg>
1. Assert: Type(_receiver_) is Object.
1. Assert: _fieldRecord_ is a Record as created by ClassFieldDefinitionEvaluation.
1. Let _fieldName_ be _fieldRecord_.[[Name]].
1. Let _initializer_ be _fieldRecord_.[[Initializer]].
1. If _initializer_ is not ~empty~, then
1. Let _initValue_ be ? Call(_initializer_, _receiver_).
1. Else, let _initValue_ be *undefined*.
1. If _name_ is a Private Name,
1. Assert: _name_.[[PrivateNameType]] is ~field~.
1. Perform ? PrivateFieldAdd(_name_, _O_, _initialValue_).
1. Otherwise, _name_ is a property key,
1. Let _desc_ be PropertyDescriptor{
[[Configurable]]: *false*,
[[Enumerable]]: *true*,
[[Writable]]: *true*,
[[Value]]: _initValue_
}.
1. Perform ? DefinePropertyOrThrow (_F_, _fieldName_, _desc_).
<emu-alg>
</emu-clause>
<emu-clause id="initialize-public-static-fields">
<h1>InitializeStaticFields(_F_)</h1>
<emu-alg>
1. Assert: Type(_F_) is Object.
1. Assert: _F_ is an ECMAScript function object.
1. Let _fieldRecords_ be the value of _F_'s [[Fields]] internal slot.
1. For each item _fieldRecord_ in order from _fieldRecords_,
1. If _fieldRecord_.[[static]] is *true*, then
1. Perform ? DefineField(_F_, _fieldRecord_).
1. Return.
</emu-alg>
</emu-clause>
<emu-clause id="initialize-public-instance-fields">
<h1>InitializeInstanceFields ( _O_, _constructor_ )</h1>
<emu-alg>
1. Assert: Type ( _O_ ) is Object.
1. Assert: Assert _constructor_ is an ECMAScript function object.
1. Let _fieldRecords_ be the value of _constructor_'s [[Fields]] internal slot.
1. For each item _fieldRecord_ in order from _fieldRecords_,
1. If _fieldRecord_.[[static]] is *false*, then
1. Perform ? DefineField(_O_, _fieldRecord_).
1. Return.
</emu-alg>
<emu-note editor>Private fields are added to the object one by one, interspersed with evaluation of the initializers, following the construction of the receiver. These semantics allow for a later initializer to refer to a previously private field.</emu-note>
</emu-clause>
<emu-clause id="sec-private-names-static-semantics-stringvalue">
<h1>Static Semantics: StringValue</h1>
<emu-see-also-para op="StringValue"></emu-see-also-para>
<emu-grammar>
PrivateName ::
`#` IdentifierName
</emu-grammar>
<emu-alg>
1. Return the String value consisting of the sequence of code units corresponding to |PrivateName|. In determining the sequence any occurrences of `\\` |UnicodeEscapeSequence| are first replaced with the code point represented by the |UnicodeEscapeSequence| and then the code points of the entire |PrivateName| are converted to code units by UTF16Encoding (<emu-xref href="#sec-utf16encoding"></emu-xref>) each code point.
</emu-alg>
</emu-clause>
<emu-clause id="sec-private-bound-names" aoid="PrivateBoundNames">
<h1>Static Semantics: PrivateBoundNames</h1>
<emu-grammar>
FieldDefinitionList : FieldDefinition
</emu-grammar>
<emu-alg>
1. Return PrivateBoundNames of |FieldDefinition|
</emu-alg>
<emu-grammar>
FieldDefinitionList :
FieldDefinitionList `,` FieldDefinition
</emu-grammar>
<emu-alg>
1. Let _names_ be PrivateBoundNames of |FieldDefinitionList|.
1. Let _additionalNames_ be PrivateBoundNames of |FieldDefinition|.
1. Append the elements of _additionalNames_ to _names_.
1. Return _names_.
</emu-alg>
<emu-grammar>
FieldDefinition : ClassElementName Initializer?
</emu-grammar>
<emu-alg>
1. Return PrivateBoundNames of |ClassElementName|
</emu-alg>
<emu-grammar>
ClassElementName : PrivateName
</emu-grammar>
<emu-alg>
1. Return a new List containing the StringValue of |PrivateName|.
</emu-alg>
<emu-grammar>
ClassElementName : PropertyName
</emu-grammar>
<emu-alg>
1. Return a new empty List.
</emu-alg>
<emu-grammar>
ClassElement : MethodDefinition
ClassElement : `static` MethodDefinition
</emu-grammar>
<emu-alg>
1. Return PrivateBoundNames of |MethodDefinition|.
</emu-alg>
<emu-grammar>
MethodDefinition[Yield, Await] :
<del>PropertyName</del><ins>ClassElementName</ins>[?Yield, ?Await] `(` UniqueFormalParameters[~Yield, ~Await] `)` `{` FunctionBody[~Yield, ~Await] `}`
`get` <del>PropertyName</del><ins>ClassElementName</ins>[?Yield, ?Await] `(` `)` `{` FunctionBody[~Yield, ~Await] `}`
`set` <del>PropertyName</del><ins>ClassElementName</ins>[?Yield, ?Await] `(` PropertySetParameterList `)` `{` FunctionBody[~Yield, ~Await] `}`
GeneratorMethod[Yield, Await] :
`*` <del>PropertyName</del><ins>ClassElementName</ins>[?Yield, ?Await] `(` UniqueFormalParameters[+Yield, ~Await] `)` `{` GeneratorBody `}`
AsyncMethod[Yield, Await] :
`async` [no LineTerminator here] <del>PropertyName</del><ins>ClassElementName</ins>[?Yield, ?Await] `(` UniqueFormalParameters[~Yield, +Await] `)` `{` AsyncFunctionBody `}`
</emu-grammar>
<emu-alg>
1. Return PrivateBoundNames of |ClassElementName|.
</emu-alg>
<emu-grammar>
MethodDefinition[Yield, Await] : GeneratorMethod[?Yield, ?Await]
</emu-grammar>
<emu-alg>
1. Return PrivateBoundNames of |GeneratorMethod|.
</emu-alg>
<emu-grammar>
MethodDefinition[Yield, Await] : AsyncMethod[?Yield, ?Await]
</emu-grammar>
<emu-alg>
1. Return PrivateBoundNames of |AsyncMethod|.
</emu-alg>
<emu-grammar>
ClassElement : `;`
</emu-grammar>
<emu-alg>
1. Return a new empty List.
</emu-alg>
<emu-grammar>
ClassElementList : ClassElement
</emu-grammar>
<emu-alg>
1. Return PrivateBoundNames of |ClassElement|.
</emu-alg>
<emu-grammar>
ClassElementList : ClassElementList ClassElement
</emu-grammar>
<emu-alg>
1. Let _names_ be PrivateBoundNames of |ClassElementList|.
1. Append to _names_ the elements of PrivateBoundNames of |ClassElement|.
1. Return _names_.
</emu-alg>
<emu-grammar>
ClassBody : ClassElementList
</emu-grammar>
<emu-alg>
1. Return PrivateBoundNames of |ClassElementList|.
</emu-alg>
</emu-clause>
<emu-clause id="static-semantics-is-static">
<h1>Static Semantics: IsStatic</h1>
<ins class="block">
<emu-grammar>ClassElement : FieldDefinitionList</emu-grammar>
<emu-alg>
1. Return *false*.
</emu-alg>
<emu-grammar>ClassElement : static FieldDefinitionList</emu-grammar>
<emu-alg>
1. Return *true*.
</emu-alg>
</ins>
</emu-clause>
<emu-clause id="runtime-semantics-class-definition-evaluation">
<h1>Runtime Semantics: ClassDefinitionEvaluation</h1>
<p>With parameter _className_.</p>
<emu-grammar>ClassTail : ClassHeritage? `{` ClassBody? `}`</emu-grammar>
<emu-alg>
1. Let _lex_ be the LexicalEnvironment of the running execution context.
1. Let _classScope_ be NewDeclarativeEnvironment(_lex_).
1. Let _classScopeEnvRec_ be _classScope_'s EnvironmentRecord.
1. If _className_ is not *undefined*, then
1. Perform _classScopeEnvRec_.CreateImmutableBinding(_className_, *true*).
1. <ins>Let _outerPrivateEnvironment_ be the PrivateNameEnvironment of the running execution context.</ins>
1. <ins>Let _classPrivateEnvironment_ be NewDeclarativeEnvironment(_outerPrivateEnvironment_).</ins>
1. <ins>Let _classPrivateEnvRec_ be _classPrivateEnvironment_'s EnvironmentRecord.</ins>
1. <ins>If |ClassBody_opt| is present, then</ins>
1. <ins>For each element _dn_ of the PrivateBoundNames of |ClassBody_opt|,</ins>
1. <ins>Perform _classPrivateEnvRec_.CreateImmutableBinding(_dn_, *true*).</ins>
1. If |ClassHeritage_opt| is not present, then
1. Let _protoParent_ be the intrinsic object %ObjectPrototype%.
1. Let _constructorParent_ be the intrinsic object %FunctionPrototype%.
1. Else,
1. Set the running execution context's LexicalEnvironment to _classScope_.
1. Let _superclass_ be the result of evaluating |ClassHeritage|.
1. Set the running execution context's LexicalEnvironment to _lex_.
1. ReturnIfAbrupt(_superclass_).
1. If _superclass_ is *null*, then
1. Let _protoParent_ be *null*.
1. Let _constructorParent_ be the intrinsic object %FunctionPrototype%.
1. Else if IsConstructor(_superclass_) is *false*, throw a *TypeError* exception.
1. Else,
1. Let _protoParent_ be ? Get(_superclass_, `"prototype"`).
1. If Type(_protoParent_) is neither Object nor Null, throw a *TypeError* exception.
1. Let _constructorParent_ be _superclass_.
1. Let _proto_ be ObjectCreate(_protoParent_).
1. If |ClassBody_opt| is not present, let _constructor_ be ~empty~.
1. Else, let _constructor_ be ConstructorMethod of |ClassBody|.
1. If _constructor_ is ~empty~, then
1. If |ClassHeritage_opt| is present and _protoParent_ is not *null*, then
1. Let _constructor_ be the result of parsing the source text
<pre><code class="javascript">constructor(... args){ super (...args);}</code></pre>
using the syntactic grammar with the goal symbol |MethodDefinition[~Yield]|.
1. Else,
1. Let _constructor_ be the result of parsing the source text
<pre><code class="javascript">constructor( ){ }</code></pre>
using the syntactic grammar with the goal symbol |MethodDefinition[~Yield]|.
1. Set the running execution context's LexicalEnvironment to _classScope_.
1. <ins>Set the running execution context's PrivateNameEnvironment to _classPrivateEnvironment_.</ins>
1. Let _constructorInfo_ be the result of performing DefineMethod for _constructor_ with arguments _proto_ and _constructorParent_ as the optional _functionPrototype_ argument.
1. Assert: _constructorInfo_ is not an abrupt completion.
1. Let _F_ be _constructorInfo_.[[Closure]].
1. If |ClassHeritage_opt| is present and _protoParent_ is not *null*, then set _F_.[[ConstructorKind]] to `"derived"`.
1. Perform MakeConstructor(_F_, *false*, _proto_).
1. Perform MakeClassConstructor(_F_).
1. Perform CreateMethodProperty(_proto_, `"constructor"`, _F_).
1. If |ClassBody_opt| is not present, let _methods_ be a new empty List.
1. Else, let _methods_ be NonConstructorMethodDefinitions of |ClassBody|. <ins>NOTE: _methods_ includes field declarations</ins>
1. Let _fieldRecords_ be a new empty List.
1. For each |ClassElement| _m_ in order from _methods_
1. If IsStatic of _m_ is *false*, then
1. Let _fields_ be the result of performing PropertyDefinitionEvaluation for _m_ with arguments _proto_ and *false*.
1. Else,
1. Let _fields_ be the result of performing PropertyDefinitionEvaluation for _m_ with arguments _F_ and *false*.
1. If _fields_ is an abrupt completion, then
1. Set the running execution context's LexicalEnvironment to _lex_.
1. <ins>Set the running execution context's PrivateNameEnvironment to _outerPrivateEnvironment_.</ins>
1. Return Completion(_status_).
1. <ins>Append _fields_ to _fieldRecords_</ins>
1. Set the running execution context's LexicalEnvironment to _lex_.
1. If _className_ is not *undefined*, then
1. Perform _classScopeEnvRec_.InitializeBinding(_className_, _F_).
1. <ins>Set the value of _F_'s [[Fields]] internal slot to _fieldRecords_.</ins>
1. <ins>Set the running execution context's LexicalEnvironment to _classScope_.</ins>
1. <ins>Set the running execution context's PrivateNameEnvironment to _outerPrivateEnvironment_.</ins>
1. <ins>Let _result_ be InitializeStaticFields(_F_).</ins>
1. <ins>If _result_ is an abrupt completion, then</ins>
1. <ins>Set the running execution context's LexicalEnvironment to _lex_.</ins>
1. <ins>Return Completion(_result_)</ins>
1. <ins>Set the running execution context's LexicalEnvironment to _lex_.</ins>
1. Return _F_.
</emu-alg>
</emu-clause>
<!-- es6num="14.3.9" -->
<emu-clause id="sec-method-definitions-runtime-semantics-propertydefinitionevaluation">
<h1>Runtime Semantics: PropertyDefinitionEvaluation</h1>
<p>With parameters _object_ and _enumerable_.</p>
<emu-see-also-para op="PropertyDefinitionEvaluation"></emu-see-also-para>
<emu-grammar>MethodDefinition : PropertyName `(` UniqueFormalParameters `)` `{` FunctionBody `}`</emu-grammar>
<emu-alg>
1. Let _methodDef_ be DefineMethod of |MethodDefinition| with argument _object_.
1. ReturnIfAbrupt(_methodDef_).
1. <ins>If _methodDef_.[[Key]] is a Private Name</ins>
1. <ins>Perform SetFunctionName(_methodDef_.[[Closure]], StringValue of _methodDef_.[[Key]]).</ins>
1. <ins>Assert: _methodDef_.[[Key]] does not have either of the internal slots [[PrivateNameType]] or [[PrivateNameMethod]].</ins>
1. <ins>Set _methodDef_.[[Key]].[[PrivateNameType]] to ~method~.</ins>
1. <ins>Set _methodDef_.[[Key]].[[PrivateNameMethod]] to _methodDef_.[[Closure]].</ins>
1. <ins>Return a new empty List.</ins>
1. Perform SetFunctionName(_methodDef_.[[Closure]], _methodDef_.[[Key]]).
1. Let _desc_ be the PropertyDescriptor{[[Value]]: _methodDef_.[[Closure]], [[Writable]]: *true*, [[Enumerable]]: _enumerable_, [[Configurable]]: *true*}.
1. Perform ? DefinePropertyOrThrow(_object_, _methodDef_.[[Key]], _desc_).
1. Return a new empty List.
</emu-alg>
<emu-grammar>MethodDefinition : `get` PropertyName `(` `)` `{` FunctionBody `}`</emu-grammar>
<emu-alg>
1. Let _propKey_ be the result of evaluating |PropertyName|.
1. ReturnIfAbrupt(_propKey_).
1. If the function code for this |MethodDefinition| is strict mode code, let _strict_ be *true*. Otherwise let _strict_ be *false*.
1. Let _scope_ be the running execution context's LexicalEnvironment.
1. Let _formalParameterList_ be an instance of the production <emu-grammar>FormalParameters : [empty]</emu-grammar>.
1. Let _closure_ be FunctionCreate(~Method~, _formalParameterList_, |FunctionBody|, _scope_, _strict_).
1. Perform MakeMethod(_closure_, _object_).
1. <ins>If _propKey_ is a Private Name</ins>
1. <ins>Perform SetFunctionName(_methodDef_.[[Closure]], StringValue of _propKey_, `"get"`).</ins>
1. <ins>If _propKey_.[[PrivateNameType]] does not exist,
1. <ins>Set _propKey_.[[PrivateNameType]] to ~accessor~.
1. <ins>Otherwise, Assert: _propKey_.[[PrivateNameType]] is already ~accessor~.</ins>
1. <ins>Assert: _propKey_ does not have the internal slot [[PrivateNameGetter]].</ins>
1. <ins>Set _propKey_.[[PrivateNameGetter]] to _methodDef_.[[Closure]].</ins>
1. <ins>Return a new empty List.</ins>
1. Perform SetFunctionName(_closure_, _propKey_, `"get"`).
1. Let _desc_ be the PropertyDescriptor{[[Get]]: _closure_, [[Enumerable]]: _enumerable_, [[Configurable]]: *true*}.
1. Perform ? DefinePropertyOrThrow(_object_, _propKey_, _desc_).
1. Return a new empty List.
</emu-alg>
<emu-grammar>MethodDefinition : `set` PropertyName `(` PropertySetParameterList `)` `{` FunctionBody `}`</emu-grammar>
<emu-alg>
1. Let _propKey_ be the result of evaluating |PropertyName|.
1. ReturnIfAbrupt(_propKey_).
1. If the function code for this |MethodDefinition| is strict mode code, let _strict_ be *true*. Otherwise let _strict_ be *false*.
1. Let _scope_ be the running execution context's LexicalEnvironment.
1. Let _closure_ be FunctionCreate(~Method~, |PropertySetParameterList|, |FunctionBody|, _scope_, _strict_).
1. Perform MakeMethod(_closure_, _object_).
1. <ins>If _propKey_ is a Private Name</ins>
1. <ins>Perform SetFunctionName(_methodDef_.[[Closure]], StringValue of _propKey_, `"get"`).</ins>
1. <ins>If _propKey_.[[PrivateNameType]] does not exist,
1. <ins>Set _propKey_.[[PrivateNameType]] to ~accessor~.
1. <ins>Otherwise, Assert: _propKey_.[[PrivateNameType]] is already ~accessor~.</ins>
1. <ins>Assert: _propKey_ does not have the internal slot [[PrivateNameSetter]].</ins>
1. <ins>Set _propKey_.[[PrivateNameSetter]] to _methodDef_.[[Closure]].</ins>
1. <ins>Return a new empty List.</ins>
1. Perform SetFunctionName(_closure_, _propKey_, `"set"`).
1. Let _desc_ be the PropertyDescriptor{[[Set]]: _closure_, [[Enumerable]]: _enumerable_, [[Configurable]]: *true*}.
1. Perform ? DefinePropertyOrThrow(_object_, _propKey_, _desc_).
1. Return a new empty List.
</emu-alg>
<emu-grammar>GeneratorMethod : `*` PropertyName `(` UniqueFormalParameters `)` `{` GeneratorBody `}`</emu-grammar>
<emu-alg>
1. Let _propKey_ be the result of evaluating |PropertyName|.
1. ReturnIfAbrupt(_propKey_).
1. If the function code for this |GeneratorMethod| is strict mode code, let _strict_ be *true*. Otherwise let _strict_ be *false*.
1. Let _scope_ be the running execution context's LexicalEnvironment.
1. Let _closure_ be GeneratorFunctionCreate(~Method~, |UniqueFormalParameters|, |GeneratorBody|, _scope_, _strict_).
1. Perform MakeMethod(_closure_, _object_).
1. Let _prototype_ be ObjectCreate(%GeneratorPrototype%).
1. Perform DefinePropertyOrThrow(_closure_, `"prototype"`, PropertyDescriptor{[[Value]]: _prototype_, [[Writable]]: *true*, [[Enumerable]]: *false*, [[Configurable]]: *false*}).
1. <ins>If _propKey_ is a Private Name</ins>
1. <ins>Perform SetFunctionName(_closure_, StringValue of _propKey_).</ins>
1. <ins>Assert: _propKey_ does not have either of the internal slots [[PrivateNameType]] or [[PrivateNameMethod]].</ins>
1. <ins>Set _propKey_.[[PrivateNameType]] to ~method~.</ins>
1. <ins>Set _propKey_.[[PrivateNameMethod]] to _closure_.</ins>
1. <ins>Return a new empty List.</ins>
1. Perform SetFunctionName(_closure_, _propKey_).
1. Let _desc_ be the PropertyDescriptor{[[Value]]: _closure_, [[Writable]]: *true*, [[Enumerable]]: _enumerable_, [[Configurable]]: *true*}.
1. Perform ? DefinePropertyOrThrow(_object_, _propKey_, _desc_).
1. Return a new empty List.
</emu-alg>
<emu-grammar>
AsyncMethod : `async` [no LineTerminator here] PropertyName `(` UniqueFormalParameters `)` `{` AsyncFunctionBody `}`
</emu-grammar>
<emu-alg>
1. Let _propKey_ be the result of evaluating |PropertyName|.
1. ReturnIfAbrupt(_propKey_).
1. If the function code for this |AsyncMethod| is strict mode code, let _strict_ be *true*. Otherwise let _strict_ be *false*.
1. Let _scope_ be the LexicalEnvironment of the running execution context.
1. Let _closure_ be ! AsyncFunctionCreate(~Method~, |UniqueFormalParameters|, |AsyncFunctionBody|, _scope_, _strict_).
1. Perform ! MakeMethod(_closure_, _object_).
1. <ins>If _propKey_ is a Private Name</ins>
1. <ins>Perform SetFunctionName(_closure_, StringValue of _propKey_).</ins>
1. <ins>Assert: _propKey_ does not have either of the internal slots [[PrivateNameType]] or [[PrivateNameMethod]].</ins>
1. <ins>Set _propKey_.[[PrivateNameType]] to ~method~.</ins>
1. <ins>Set _propKey_.[[PrivateNameMethod]] to _closure_.</ins>
1. <ins>Return a new empty List.</ins>
1. Perform ! SetFunctionName(_closure_, _propKey_).
1. Let _desc_ be the PropertyDescriptor{[[Value]]: _closure_, [[Writable]]: *true*, [[Enumerable]]: _enumerable_, [[Configurable]]: *true*}.
1. Perform ? DefinePropertyOrThrow(_object_, _propKey_, _desc_).
1. Return a new empty List.
</emu-alg>
<emu-grammar>ClassElement : `static` FieldDefinitionList `;`</emu-grammar>
<emu-alg>
1. Return ClassFieldDefinitionEvaluation of FieldDefinitionList with parameter *true* and _object_.
</emu-alg>
<emu-grammar>ClassElement : FieldDefinitionList `;`</emu-grammar>
<emu-alg>
1. Return ClassFieldDefinitionEvaluation of FieldDefinitionList with parameter *false* and _object_.
</emu-alg>
</emu-clause>
<emu-clause id="runtime-semantics-class-field-definition-evaluation">
<h1>Runtime Semantics: ClassFieldDefinitionEvaluation</h1>
<p>With parameters _isStatic_ and _homeObject_.</p>
<emu-grammar>
FieldDefinitionList[Yield, Await] : FieldDefinitionList[?Yield, ?Await] `,` FieldDefinition[?Yield, ?Await]
</emu-grammar>
<emu-alg>
1. Let _fields_ be ClassFieldDefinitionEvaluation of |FieldDefinitionList|.
1. Let _field_ be ClassFieldDefinitionEvaluation of |FieldDefinition|.
1. Append _field_ to _fields_.
1. Return _fields_.
</emu-alg>
<emu-grammar>
FieldDefinitionList[Yield, Await] : FieldDefinition[?Yield, ?Await]
</emu-grammar>
<emu-alg>
1. Return a List containing ClassFieldDefinitionEvaluation of |FieldDefinition|.
</emu-alg>
<emu-grammar>
FieldDefinition : ClassElementName Initializer? `;`
</emu-grammar>
<emu-alg>
1. Let _fieldName_ be the result of evaluating |ClassElementName|.
1. If |Initializer_opt| is present,
1. Let _lex_ be the Lexical Environment of the running execution context.
1. Let _initializer_ be FunctionCreate(~Method~, ~empty~, |Initializer|, _lex_, *true*).
1. Perform MakeMethod(_initializer_, _homeObject_).
1. Else, let _initializer_ be ~empty~.
1. If _fieldName_ is a Private Name, set _fieldName_.[[PrivateNameType]] to ~field~.
1. Return Record {
[[Name]]: _fieldName_,
[[Initializer]]: _initializer_,
[[Static]]: _isStatic_,
}.
</emu-alg>
</emu-clause>
<emu-clause id="[[construct]]">
<h1>[[Construct]] ( _argumentsList_, _newTarget_)</h1>
<p>
The [[Construct]] internal method for an ECMAScript Function object _F_ is
called with parameters _argumentsList_ and _newTarget_. _argumentsList_ is
a possibly empty List of ECMAScript language values. The following steps are
taken:
</p>
<emu-alg>
1. Assert: _F_ is an ECMAScript function object.
1. Assert: Type(_newTarget_) is Object.
1. Let _callerContext_ be the running execution context.
1. Let _kind_ be _F_.[[ConstructorKind]].
1. If _kind_ is `"base"`, then
1. Let _thisArgument_ be ? OrdinaryCreateFromConstructor(_newTarget_, `"%ObjectPrototype%"`).
1. Let _calleeContext_ be PrepareForOrdinaryCall(_F_, _newTarget_).
1. Assert: _calleeContext_ is now the running execution context.
1. If _kind_ is `"base"`, then
1. Perform OrdinaryCallBindThis(_F_, _calleeContext_, _thisArgument_).
1. <ins>Let _result_ be InitializeInstanceFields(_thisArgument_, _F_).</ins>
1. <ins>If _result_ is an abrupt completion, then</ins>
1. <ins>Remove _calleeContext_ from execution context stack and restore
_callerContext_ as the running execution context.</ins>
1. <ins>Return Completion(_result_).</ins>
1. Let _constructorEnv_ be the LexicalEnvironment of _calleeContext_.
1. Let _envRec_ be _constructorEnv_'s EnvironmentRecord.
1. Let _result_ be OrdinaryCallEvaluateBody(_F_, _argumentsList_).
1. Remove _calleeContext_ from the execution context stack and restore _callerContext_ as the running execution context.
1. If _result_.[[Type]] is ~return~, then
1. If Type(_result_.[[Value]]) is Object, return NormalCompletion(_result_.[[Value]]).
1. If _kind_ is `"base"`, return NormalCompletion(_thisArgument_).
1. If _result_.[[Value]] is not *undefined*, throw a *TypeError* exception.
1. Else, ReturnIfAbrupt(_result_).
1. Return ? _envRec_.GetThisBinding().
</emu-alg>
<emu-note editor>Fields are added by the base class constructor when the super chain reaches up to that, rather than by the subclass constructor when creating the object, in order to be analogous to ES2015 subclassable builtins. See <a href="https://github.com/tc39/proposal-private-fields/issues/17">this GitHub thread</a> for more discussion.</emu-note>
</emu-clause>
<emu-clause id="the-super-keyword">
<h1>The `super` Keyword</h1>
<emu-clause id="sec-super-keyword-runtime-semantics-evaluation">
<h1>Runtime Semantics: Evaluation</h1>
<emu-grammar>SuperCall : `super` Arguments</emu-grammar>
<emu-alg>
1. Let _newTarget_ be GetNewTarget().
1. If _newTarget_ is *undefined*, throw a *ReferenceError* exception.
1. Let _func_ be ? GetSuperConstructor().
1. Let _argList_ be ArgumentListEvaluation of |Arguments|.
1. ReturnIfAbrupt(_argList_).
1. Let _result_ be ? Construct(_func_, _argList_, _newTarget_).
1. Let _thisER_ be GetThisEnvironment( ).
1. <ins>Perform ? InitializeInstanceFields(_thisValue_, _F_).</ins>
1. Return ? _thisER_.BindThisValue(_result_).
</emu-alg>
</emu-clause>
</emu-clause>
<emu-clause id="sec-delete-operator">
<h1>The `delete` Operator</h1>
<emu-clause id="sec-delete-operator-runtime-semantics-evaluation">
<h1>Runtime Semantics: Evaluation</h1>
<emu-grammar>UnaryExpression : `delete` UnaryExpression</emu-grammar>
<emu-alg>
1. Let _ref_ be the result of evaluating |UnaryExpression|.
1. ReturnIfAbrupt(_ref_).
1. If Type(_ref_) is not Reference, return *true*.
1. If IsUnresolvableReference(_ref_) is *true*, then
1. Assert: IsStrictReference(_ref_) is *false*.
1. Return *true*.
1. If IsPropertyReference(_ref_) is *true*, then
1. <ins>Assert: IsPrivateReference(_ref_) is *false*.</ins>
1. If IsSuperReference(_ref_), throw a *ReferenceError* exception.
1. Let _baseObj_ be ! ToObject(GetBase(_ref_)).
1. Let _deleteStatus_ be ? _baseObj_.[[Delete]](GetReferencedName(_ref_)).
1. If _deleteStatus_ is *false* and IsStrictReference(_ref_) is *true*, throw a *TypeError* exception.
1. Return _deleteStatus_.
1. Else _ref_ is a Reference to an Environment Record binding,
1. Let _bindings_ be GetBase(_ref_).
1. Return ? _bindings_.DeleteBinding(GetReferencedName(_ref_)).
</emu-alg>
<emu-note>
<p>When a `delete` operator occurs within strict mode code, a *SyntaxError* exception is thrown if its |UnaryExpression| is a direct reference to a variable, function argument, or function name. In addition, if a `delete` operator occurs within strict mode code and the property to be deleted has the attribute { [[Configurable]]: *false* }, a *TypeError* exception is thrown.</p>
</emu-note>
</emu-clause>
</emu-clause>
</emu-clause>
<emu-clause id="sec-private-names">
<h1>Private Names and references</h1>
<p>The <dfn>Private Name</dfn> specification type is used to describe a globally unique identifier which represents a private field name. A private name may be installed on any ECMAScript object with the PrivateFieldAdd internal algorithm, and then read or written using PrivateFieldGet and PrivateFieldSet.</p>
<p>All ECMAScript objects have a new additional internal slot, [[PrivateFieldValues]], which is a List of Records of the form { [[PrivateName]]: Private Name, [[PrivateFieldValue]]: ECMAScript value }. This List represents the values of the private fields for the object. All objects, including Proxies and all host environment-provided objects, have this internal slot, but primitives such as Numbers do not.</p>
<p>Private Names can point to fields, methods or accessors. To model this, they have write-once internal slots which determine their behavior:<p>
<ul>
<li>[[PrivateNameType]]: Either ~field~, ~method~ or ~accessor~.</li>
<li>If the [[PrivateNameType]] is ~method~:
<ul>
<li>[[PrivateNameMethod]]: A Function object which is the method.</li>
</ul></li>
<li>If the [[PrivateNameType]] is ~accessor~:
<ul>
<li>[[PrivateNameGetter]]: A Function object which is called from GetValue.</li>
<li>[[PrivateNameSetter]]: A Function object which is called from PutValue.</li>
</ul></li>
</ul>
<emu-note editor>
<p>
Private fields are designed to have semantics analogous to WeakMaps. However, the implied garbage collection semantics are weaker: If all the references to a WeakMap are inaccessible, but there is still a reference to a key which was in the WeakMap, one would expect the value to be eventually collected. However, PrivateNameIdentifiers specifically do not have this connotation: because the reference from the Identifier to the Value is in a Record which the Object points to, the value would not be collected, even if nothing else points to the identifier.
</p>
<p>
Private Names are a specification type here, not directly observable to ECMAScript code. However, in <a href="https://github.com/tc39/proposal-private-fields/blob/master/DECORATORS.md">a decorator integration strawman</a>, an object wrapping Private Names would be exposed to allow greater metaprogramming.
</p>
</emu-note>
<emu-note editor>
Private fields are deliberately inaccessible outside of the class body. It is proposed that there could be an "escape hatch" to access them though some sort of reflective mechanism; see <a href="https://github.com/tc39/proposal-private-fields/issues/33">the GitHub thread</a>. This proposal deliberately omits any such escape hatch.
</emu-note>
<emu-clause id="sec-objectcreate" aoid="ObjectCreate">
<h1>ObjectCreate (_proto_ [ , _internalSlotsList_ ])</h1>
<p>The abstract operation ObjectCreate with argument _proto_ (an object or null) is used to specify the runtime creation of new ordinary objects. The optional argument _internalSlotsList_ is a List of the names of additional internal slots that must be defined as part of the object. If the list is not provided, a new empty List is used. This abstract operation performs the following steps:</p>
<emu-alg>
1. If _internalSlotsList_ was not provided, let _internalSlotsList_ be a new empty List.
1. Let _obj_ be a newly created object with an internal slot for each name in _internalSlotsList_.
1. Set _obj_'s essential internal methods to the default ordinary object definitions specified in <emu-xref href="#sec-ordinary-object-internal-methods-and-internal-slots"></emu-xref>.
1. Set _obj_.[[Prototype]] to _proto_.
1. Set _obj_.[[Extensible]] to *true*.
1. <ins>Set _obj_.[[PrivateFieldValues]] to an empty List.</ins>
1. Return _obj_.
</emu-alg>
<emu-note editor>TODO: All ECMAScript objects, including Proxies, and any user exotic object, should have a [[PrivateFieldValues]] internal slot iniitlaized to an empty List.</emu-note>
</emu-clause>
<emu-clause id="sec-newprivatename" aoid="NewPrivateName">
<h1>NewPrivateName ()</h1>
<emu-alg>
1. Return a new globally unique Private Name value.
</emu-alg>
</emu-clause>
<emu-clause id="sec-privatefieldfind" aoid="PrivateFieldFind">
<h1>PrivateFieldFind (_P_, _O_)</h1>
<emu-alg>
1. Assert: _P_ is a Private Name value.
1. Assert: _O_ is an object with a [[PrivateFieldValues]] internal slot.
1. For each element _entry_ in _O_.[[PrivateFieldValues]],
1. If _entry_.[[PrivateName]] is _P_, return _entry_.
1. Return ~empty~.
</emu-alg>
</emu-clause>
<emu-clause id="sec-privatefieldadd" aoid="PrivateFieldAdd">
<h1>PrivateFieldAdd (_P_, _O_, _value_)</h1>
<emu-alg>
1. Assert: _P_ is a Private Name value.
1. If _O_ is not an object, throw a *TypeError* exception.
1. Let _entry_ be PrivateFieldFind(_P_, _O_).
1. If _entry_ is not ~empty~, throw a *TypeError* exception.
1. Append { [[PrivateName]]: P, [[PrivateFieldValue]]: _value_ } to _O_.[[PrivateFieldValues]].
</emu-alg>
</emu-clause>
<emu-clause id="sec-privatefieldget" aoid="PrivateFieldGet">
<h1>PrivateFieldGet (_P_, _O_ )</h1>
<emu-alg>
1. Assert: _P_ is a Private Name value.
1. If _O_ is not an object, throw a *TypeError* exception.
1. Let _entry_ be PrivateFieldFind(_P_, _O_).
1. If _entry_ is ~empty~, throw a *TypeError* exception.
1. Return _entry_.[[PrivateFieldValue]].
</emu-alg>
</emu-clause>
<emu-clause id="sec-privatefieldset" aoid="PrivateFieldSet">
<h1>PrivateFieldSet (_P_, _O_, _value_ )</h1>
<emu-alg>
1. Assert: _P_ is a Private Name value.
1. If _O_ is not an object, throw a *TypeError* exception.
1. Let _entry_ be PrivateFieldFind(_P_, _O_).
1. If _entry_ is ~empty~, throw a *TypeError* exception.
1. Set _entry_.[[PrivateFieldValue]] to _value_.
</emu-alg>
</emu-clause>
<emu-clause id="sec-privateget" aoid="PrivateGet">
<h1>PrivateGet (_P_, _O_ )</h1>
<emu-alg>
1. Assert: _P_ is a Private Name value.
1. If _O_ is not an object, throw a *TypeError* exception.
1. If _P_.[[PrivateNameType]] is ~field~,
1. Return ? PrivateFieldGet(_P_, _O_).
1. Otherwise, if _P_.[[PrivateNameType]] is ~method~,
1. Return _P_.[[PrivateNameMethod]].
1. Otherwise, _P_.[[PrivateNameType]] is ~accessor~,
1. If _P_ does not have a [[PrivateNameGetter]] internal slot, throw a *TypeError* exception.
1. Return ? Call(_P_.[[PrivateNameGetter]], _O_).
</emu-alg>
</emu-clause>
<emu-clause id="sec-privateset" aoid="PrivateSet">
<h1>PrivateSet (_P_, _O_, _value_ )</h1>
<emu-alg>
1. Assert: _P_ is a Private Name value.
1. If _O_ is not an object, throw a *TypeError* exception.
1. If _P_.[[PrivateNameType]] is ~field~,
1. Return ? PrivateFieldSet(_P_, _O_, _value_).
1. Otherwise if _P_.[[PrivateNameType]] is ~method~,
1. Throw a *TypeError* exception.
1. Otherwise, _P_.[[PrivateNameType]] is ~accessor~,
1. If _P_ does not have a [[PrivateNameSetter]] internal slot, throw a *TypeError* exception.
1. Return ? Call(_P_.[[PrivateNameSetter]], _O_, _V_).
</emu-alg>
</emu-clause>
<emu-clause id="sec-private-references-runtime-semantics-evaluation">
<h1>Runtime Semantics: Evaluation</h1>
<emu-grammar>MemberExpression : MemberExpression `.` PrivateName</emu-grammar>
<emu-alg>
1. Let _baseReference_ be the result of evaluating |MemberExpression|.
1. Let _baseValue_ be ? GetValue(_baseReference_).
1. Let _bv_ be ? RequireObjectCoercible(_baseValue_).
1. Let _fieldNameString_ be the StringValue of |PrivateName|.
1. Return MakePrivateReference(_bv_, _fieldNameString_).
</emu-alg>
<emu-grammar>PrimaryExpression : PrivateName</emu-grammar>
<emu-alg>