super-call.js (1115B)
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-scripts-static-semantics-early-errors 5 es6id: 15.1.1 6 description: > 7 An indirect eval may not contain SuperCall 8 info: | 9 - It is a Syntax Error if StatementList Contains super unless the source code 10 containing super is eval code that is being processed by a direct eval that 11 is contained in function code that is not the function code of an 12 ArrowFunction. 13 features: [super] 14 ---*/ 15 16 var caught; 17 18 try { 19 (0,eval)('super();'); 20 } catch (err) { 21 caught = err; 22 } 23 24 assert.sameValue(typeof caught, 'object', 'object value thrown (global code)'); 25 assert.sameValue( 26 caught.constructor, SyntaxError, 'SyntaxError thrown (global code)' 27 ); 28 29 caught = null; 30 31 try { 32 ({ 33 m() { 34 (0,eval)('super();'); 35 } 36 }).m(); 37 } catch (err) { 38 caught = err; 39 } 40 41 assert.sameValue( 42 typeof caught, 'object', 'object value thrown (function code)' 43 ); 44 assert.sameValue( 45 caught.constructor, SyntaxError, 'SyntaxError thrown (function code)' 46 ); 47 48 reportCompare(0, 0);