tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

static-field-redeclaration.js (2363B)


      1 // This file was procedurally generated from the following sources:
      2 // - src/class-elements/static-field-redeclaration.case
      3 // - src/class-elements/default/cls-expr.template
      4 /*---
      5 description: Static fields can be redeclared (field definitions in a class expression)
      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 var C = class {
     60  static f = 'test';
     61  static f = this.f + '262';
     62  static g() {
     63    return 45;
     64  };
     65  static g = this.g();
     66 }
     67 
     68 assert.sameValue(C.f, 'test262');
     69 assert.sameValue(C.g, 45);
     70 
     71 reportCompare(0, 0);