tor-browser

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

fielddefinition-initializer-abrupt-completion.js (1683B)


      1 // Copyright (C) 2017 Valerie Young. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 description: Class construction should error if evaluation of field initializer errors
      6 esid: sec-ecmascript-function-objects-construct-argumentslist-newtarget
      7 info: |
      8  [[Construct]] ( argumentsList, newTarget)
      9    ...
     10    8. If kind is "base", then
     11      a. Perform OrdinaryCallBindThis(F, calleeContext, thisArgument).
     12      b. Let result be InitializeInstanceFields(thisArgument, F).
     13      c. If result is an abrupt completion, then
     14        i. Remove calleeContext from execution context stack and restore callerContext as the running execution context.
     15        ii. Return Completion(result).
     16 
     17  InitializeInstanceFields ( O, constructor )
     18    1. Assert: Type ( O ) is Object.
     19    2. Assert: Assert constructor is an ECMAScript function object.
     20    3. Let fieldRecords be the value of constructor's [[Fields]] internal slot.
     21    4. For each item fieldRecord in order from fieldRecords,
     22      a. If fieldRecord.[[static]] is false, then
     23        i. Perform ? DefineField(O, fieldRecord).
     24 
     25  DefineField(receiver, fieldRecord)
     26    1. Assert: Type(receiver) is Object.
     27    2. Assert: fieldRecord is a Record as created by ClassFieldDefinitionEvaluation.
     28    3. Let fieldName be fieldRecord.[[Name]].
     29    4. Let initializer be fieldRecord.[[Initializer]].
     30    5. If initializer is not empty, then
     31        a.Let initValue be ? Call(initializer, receiver).
     32 
     33 features: [class, class-fields-public]
     34 ---*/
     35 
     36 function f() {
     37  throw new Test262Error();
     38 }
     39 
     40 class C {
     41  x = f();
     42 }
     43 
     44 assert.throws(Test262Error, function() {
     45  new C();
     46 })
     47 
     48 reportCompare(0, 0);