| 1 |
// This file was procedurally generated from the following sources: |
| 2 |
// - src/class-fields/eval-err-contains-newtarget.case |
| 3 |
// - src/class-fields/initializer-eval-newtarget/cls-expr-fields-eval.template |
| 4 |
/*--- |
| 5 |
description: error if `new.target` in StatementList of eval (direct eval) |
| 6 |
esid: sec-performeval-rules-in-initializer |
| 7 |
features: [class, class-fields-public] |
| 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 executed = false; |
| 27 |
var C = class { |
| 28 |
x = eval('executed = true; new.target;'); |
| 29 |
} |
| 30 |
|
| 31 |
var c = new C(); |
| 32 |
|
| 33 |
assert.sameValue(executed, true); |
| 34 |
assert.sameValue(c.x, undefined); |