new.target-fn.js (839B)
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 A direct eval in the functon code of a non-ArrowFunction may contain 8 `new.target` 9 info: | 10 - It is a Syntax Error if StatementList Contains NewTarget unless the source 11 code containing NewTarget is eval code that is being processed by a direct 12 eval that is contained in function code that is not the function code of an 13 ArrowFunction. 14 features: [new.target] 15 ---*/ 16 17 var newTarget = null; 18 var getNewTarget = function() { 19 newTarget = eval('new.target;'); 20 }; 21 22 getNewTarget(); 23 24 assert.sameValue(newTarget, undefined); 25 26 new getNewTarget(); 27 28 assert.sameValue(newTarget, getNewTarget); 29 30 reportCompare(0, 0);