arrow-body-private-indirect-eval-err-contains-newtarget.js (1179B)
1 // This file was procedurally generated from the following sources: 2 // - src/class-elements/eval-err-contains-newtarget.case 3 // - src/class-elements/initializer-eval-newtarget/cls-expr-private-fields-indirect-eval-arrow-body.template 4 /*--- 5 description: error if `new.target` in StatementList of eval (indirect eval) 6 esid: sec-performeval-rules-in-initializer 7 features: [class, new.target, class-fields-private] 8 flags: [generated] 9 info: | 10 Additional Early Error Rules for Eval Inside Initializer 11 These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. 12 ScriptBody : StatementList 13 14 ... 15 The remaining eval rules apply as outside a constructor, inside a method, and inside a function. 16 17 Additional Early Error Rules for Eval Outside Functions 18 These static semantics are applied by PerformEval when a direct eval call occurs outside of any function. 19 ScriptBody : StatementList 20 21 It is a Syntax Error if StatementList Contains NewTarget. 22 23 ---*/ 24 25 26 var C = class { 27 #x = (0, eval)('() => new.target;'); 28 } 29 30 assert.throws(SyntaxError, function() { 31 new C().x(); 32 }); 33 34 35 reportCompare(0, 0);