Debian Codegraph @

js/src/tests/test262/language/statements/class/elements/static-field-init-this-inside-arrow-function.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/class-elements/static-field-init-this-inside-arrow-function.case
3 // - src/class-elements/default/cls-decl.template
4 /*---
5 description: this in static field initializers refers to class constructor (field definitions in a class declaration)
6 esid: prod-FieldDefinition
7 features: [class-static-fields-public, class]
8 flags: [generated]
9 info: |
10 Updated Productions
11
12 ClassElement :
13 ...
14 static FieldDefinition ;
15
16 FieldDefinition :
17 ClassElementName Initializer_opt
18
19 ClassDefinitionEvaluation:
20 ...
21
22 27. Let staticFields be a new empty List.
23 28. For each ClassElement e in order from elements,
24 a. If IsStatic of e is false, then
25 ...
26 b. Else,
27 i. Let field be the result of performing PropertyDefinitionEvaluation for m ClassElementEvaluation for e with arguments F and false.
28 c. If field is an abrupt completion, then
29 ...
30 d. If field is not empty,
31 i. If IsStatic of e is false, append field to instanceFields.
32 ii. Otherwise, append field to staticFields.
33
34 34. For each item fieldRecord in order from staticFields,
35 a. Perform ? DefineField(F, field).
36 ...
37
38 DefineField(receiver, fieldRecord)
39 1. Assert: Type(receiver) is Object.
40 2. Assert: fieldRecord is a Record as created by ClassFieldDefinitionEvaluation.
41 3. Let name be fieldRecord.[[Name]].
42 4. Let initializer be fieldRecord.[[Initializer]].
43 5. If initializer is not empty, then
44 a. Let initValue be ? Call(initializer, receiver).
45 6. Else, let initValue be undefined.
46 7. If fieldRecord.[[IsAnonymousFunctionDefinition]] is true, then
47 a. Let hasNameProperty be ? HasOwnProperty(initValue, "name").
48 b. If hasNameProperty is false, perform SetFunctionName(initValue, fieldName).
49 8. If fieldName is a Private Name,
50 a. Perform ? PrivateFieldAdd(fieldName, receiver, initValue).
51 9. Else,
52 a. Assert: IsPropertyKey(fieldName) is true.
53 b. Perform ? CreateDataPropertyOrThrow(receiver, fieldName, initValue).
54 10. Return.
55
56 ---*/
57
58
59 class C {
60 static f = () => this;
61 }
62
63 assert.sameValue(C.f(), C);
64
65 reportCompare(0, 0);