super-fielddefinition-initializer-abrupt-completion.js (1881B)
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 in super errors 6 esid: sec-super-keyword-runtime-semantics-evaluation 7 info: | 8 Runtime Semantics: Evaluation 9 SuperCall : superArguments 10 1. Let newTarget be GetNewTarget(). 11 2. If newTarget is undefined, throw a ReferenceError exception. 12 3. Let func be ? GetSuperConstructor(). 13 4. Let argList be ArgumentListEvaluation of Arguments. 14 5. ReturnIfAbrupt(argList). 15 6. Let result be ? Construct(func, argList, newTarget). 16 7. Let thisER be GetThisEnvironment( ). 17 8. Let F be thisER.[[FunctionObject]]. 18 9. Assert: F is an ECMAScript function object. 19 10. Perform ? InitializeInstanceFields(result, F). 20 21 InitializeInstanceFields ( O, constructor ) 22 1. Assert: Type ( O ) is Object. 23 2. Assert: Assert constructor is an ECMAScript function object. 24 3. Let fieldRecords be the value of constructor's [[Fields]] internal slot. 25 4. For each item fieldRecord in order from fieldRecords, 26 a. If fieldRecord.[[static]] is false, then 27 i. Perform ? DefineField(O, fieldRecord). 28 29 DefineField(receiver, fieldRecord) 30 1. Assert: Type(receiver) is Object. 31 2. Assert: fieldRecord is a Record as created by ClassFieldDefinitionEvaluation. 32 3. Let fieldName be fieldRecord.[[Name]]. 33 4. Let initializer be fieldRecord.[[Initializer]]. 34 5. If initializer is not empty, then 35 a.Let initValue be ? Call(initializer, receiver). 36 37 features: [class, class-fields-public] 38 ---*/ 39 40 function f() { 41 throw new Test262Error(); 42 } 43 44 class A { 45 x = f(); 46 } 47 48 class C extends A { 49 constructor() { 50 super(); 51 } 52 } 53 54 assert.throws(Test262Error, function() { 55 new C(); 56 }) 57 58 reportCompare(0, 0);