super-call-fn.js (1561B)
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 A direct eval in the functon code of a non-ArrowFunction may not contain 7 SuperCall 8 info: | 9 [...] 10 4. Let inMethod be false. 11 5. Let inConstructor be false. 12 6. If thisEnvRec has a [[HomeObject]] field, then 13 a. Let inMethod be true. 14 b. If thisEnvRec.[[FunctionObject]] has a [[Construct]] field, let 15 inConstructor be true. 16 7. Let script be the ECMAScript code that is the result of parsing x, 17 interpreted as UTF-16 encoded Unicode text as described in 6.1.4, for the 18 goal symbol Script. If inMethod is false, additional early error rules 19 from 18.2.1.1.1 are applied. If inConstructor is false, additional early 20 error rules from 18.2.1.1.2 are applied. If the parse fails, throw a 21 SyntaxError exception. If any early errors are detected, throw a 22 SyntaxError or a ReferenceError exception, depending on the type of the 23 error (but see also clause 16). Parsing and early error detection may be 24 interweaved in an implementation dependent manner. 25 26 18.2.1.1.1 Additional Early Error Rules for Eval Outside Methods 27 28 ScriptBody : StatementList 29 30 - It is a Syntax Error if StatementList contains super. 31 features: [super] 32 ---*/ 33 34 var executed = false; 35 function f() { 36 eval('executed = true; super();'); 37 } 38 39 assert.throws(SyntaxError, function() { 40 f(); 41 }); 42 43 assert.sameValue(executed, false); 44 45 reportCompare(0, 0);