prop-dot-cls-this-uninit.js (1593B)
1 // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 esid: sec-super-keyword 5 es6id: 12.3.5 6 description: > 7 SuperProperty evaluation when "this" binding has not been initialized 8 info: | 9 1. Let propertyKey be StringValue of IdentifierName. 10 2. If the code matched by the syntactic production that is being evaluated is 11 strict mode code, let strict be true, else let strict be false. 12 3. Return ? MakeSuperPropertyReference(propertyKey, strict). 13 14 12.3.5.3 Runtime Semantics: MakeSuperPropertyReference 15 16 1. Let env be GetThisEnvironment( ). 17 2. If env.HasSuperBinding() is false, throw a ReferenceError exception. 18 3. Let actualThis be ? env.GetThisBinding(). 19 20 8.1.1.3.4 GetThisBinding 21 22 1. Let envRec be the function Environment Record for which the method was 23 invoked. 24 2. Assert: envRec.[[ThisBindingStatus]] is not "lexical". 25 3. If envRec.[[ThisBindingStatus]] is "uninitialized", throw a ReferenceError 26 exception. 27 features: [class] 28 ---*/ 29 30 var caught; 31 class C extends Object { 32 constructor() { 33 try { 34 super.x; 35 } catch (err) { 36 caught = err; 37 } 38 } 39 } 40 41 // When the "construct" invocation completes and the "this" value is 42 // uninitialized, the specification dictates that a ReferenceError must be 43 // thrown. That behavior is tested elsewhere, so the error is ignored (if it is 44 // produced at all). 45 try { 46 new C(); 47 } catch (_) {} 48 49 assert.sameValue(typeof caught, 'object'); 50 assert.sameValue(caught.constructor, ReferenceError); 51 52 reportCompare(0, 0);