super-prop-expr-no-home-no-eval.js (1761B)
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-performeval 5 description: > 6 Expression is not evaluated prior to verification of "super" binding 7 info: | 8 [...] 9 4. Let inMethod be false. 10 5. Let inConstructor be false. 11 6. If thisEnvRec has a [[HomeObject]] field, then 12 a. Let inMethod be true. 13 b. If thisEnvRec.[[FunctionObject]] has a [[Construct]] field, let 14 inConstructor be true. 15 7. Let script be the ECMAScript code that is the result of parsing x, 16 interpreted as UTF-16 encoded Unicode text as described in 6.1.4, for the 17 goal symbol Script. If inMethod is false, additional early error rules 18 from 18.2.1.1.1 are applied. If inConstructor is false, additional early 19 error rules from 18.2.1.1.2 are applied. If the parse fails, throw a 20 SyntaxError exception. If any early errors are detected, throw a 21 SyntaxError or a ReferenceError exception, depending on the type of the 22 error (but see also clause 16). Parsing and early error detection may be 23 interweaved in an implementation dependent manner. 24 25 18.2.1.1.1 Additional Early Error Rules for Eval Outside Methods 26 27 ScriptBody : StatementList 28 29 - It is a Syntax Error if StatementList contains super. 30 features: [super] 31 ---*/ 32 33 var evaluated = false; 34 function f() { 35 // Early errors restricting the usage of SuperProperty necessitate the use of 36 // `eval`. 37 try { 38 eval('super[evaluated = true];'); 39 // Evaluation of SuperProperty is expected to fail in this context, but that 40 // behavior is tested elsewhere, so the error is discarded. 41 } catch (_) {} 42 } 43 44 f(); 45 46 assert.sameValue(evaluated, false); 47 48 reportCompare(0, 0);