From 54f4d02aa6c097a2f2674561f05406e935f5a88b Mon Sep 17 00:00:00 2001
From: Valerie R Young <valerie@bocoup.com>
Date: Thu, 26 Oct 2017 17:58:33 -0400
Subject: [PATCH] Classfields: simple early errors test for privatename
 references in scripts

---
 ...privatename-not-valid-earlyerr-module-1.js | 23 ++++++++++++
 ...privatename-not-valid-earlyerr-module-2.js | 23 ++++++++++++
 ...privatename-not-valid-earlyerr-module-3.js | 21 +++++++++++
 ...privatename-not-valid-earlyerr-module-4.js | 27 ++++++++++++++
 ...privatename-not-valid-earlyerr-module-5.js | 23 ++++++++++++
 ...privatename-not-valid-earlyerr-module-6.js | 21 +++++++++++
 ...privatename-not-valid-earlyerr-module-7.js | 21 +++++++++++
 ...privatename-not-valid-earlyerr-module-8.js | 21 +++++++++++
 ...privatename-not-valid-earlyerr-script-1.js | 24 +++++++++++++
 ...privatename-not-valid-earlyerr-script-2.js | 24 +++++++++++++
 ...privatename-not-valid-earlyerr-script-3.js | 22 ++++++++++++
 ...privatename-not-valid-earlyerr-script-4.js | 27 ++++++++++++++
 ...privatename-not-valid-earlyerr-script-5.js | 24 +++++++++++++
 ...privatename-not-valid-earlyerr-script-6.js | 22 ++++++++++++
 ...privatename-not-valid-earlyerr-script-7.js | 22 ++++++++++++
 ...privatename-not-valid-earlyerr-script-8.js | 22 ++++++++++++
 .../privatename-not-valid-eval-earlyerr-1.js  | 32 +++++++++++++++++
 .../privatename-not-valid-eval-earlyerr-2.js  | 32 +++++++++++++++++
 .../privatename-not-valid-eval-earlyerr-3.js  | 30 ++++++++++++++++
 .../privatename-not-valid-eval-earlyerr-4.js  | 35 +++++++++++++++++++
 .../privatename-not-valid-eval-earlyerr-5.js  | 30 ++++++++++++++++
 .../privatename-not-valid-eval-earlyerr-6.js  | 27 ++++++++++++++
 .../privatename-not-valid-eval-earlyerr-7.js  | 21 +++++++++++
 .../privatename-not-valid-eval-earlyerr-8.js  | 25 +++++++++++++
 24 files changed, 599 insertions(+)
 create mode 100644 test/language/module-code/privatename-not-valid-earlyerr-module-1.js
 create mode 100644 test/language/module-code/privatename-not-valid-earlyerr-module-2.js
 create mode 100644 test/language/module-code/privatename-not-valid-earlyerr-module-3.js
 create mode 100644 test/language/module-code/privatename-not-valid-earlyerr-module-4.js
 create mode 100644 test/language/module-code/privatename-not-valid-earlyerr-module-5.js
 create mode 100644 test/language/module-code/privatename-not-valid-earlyerr-module-6.js
 create mode 100644 test/language/module-code/privatename-not-valid-earlyerr-module-7.js
 create mode 100644 test/language/module-code/privatename-not-valid-earlyerr-module-8.js
 create mode 100644 test/language/statements/class/privatename-not-valid-earlyerr-script-1.js
 create mode 100644 test/language/statements/class/privatename-not-valid-earlyerr-script-2.js
 create mode 100644 test/language/statements/class/privatename-not-valid-earlyerr-script-3.js
 create mode 100644 test/language/statements/class/privatename-not-valid-earlyerr-script-4.js
 create mode 100644 test/language/statements/class/privatename-not-valid-earlyerr-script-5.js
 create mode 100644 test/language/statements/class/privatename-not-valid-earlyerr-script-6.js
 create mode 100644 test/language/statements/class/privatename-not-valid-earlyerr-script-7.js
 create mode 100644 test/language/statements/class/privatename-not-valid-earlyerr-script-8.js
 create mode 100644 test/language/statements/class/privatename-not-valid-eval-earlyerr-1.js
 create mode 100644 test/language/statements/class/privatename-not-valid-eval-earlyerr-2.js
 create mode 100644 test/language/statements/class/privatename-not-valid-eval-earlyerr-3.js
 create mode 100644 test/language/statements/class/privatename-not-valid-eval-earlyerr-4.js
 create mode 100644 test/language/statements/class/privatename-not-valid-eval-earlyerr-5.js
 create mode 100644 test/language/statements/class/privatename-not-valid-eval-earlyerr-6.js
 create mode 100644 test/language/statements/class/privatename-not-valid-eval-earlyerr-7.js
 create mode 100644 test/language/statements/class/privatename-not-valid-eval-earlyerr-8.js

diff --git a/test/language/module-code/privatename-not-valid-earlyerr-module-1.js b/test/language/module-code/privatename-not-valid-earlyerr-module-1.js
new file mode 100644
index 0000000000..03cfdfcb62
--- /dev/null
+++ b/test/language/module-code/privatename-not-valid-earlyerr-module-1.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2017 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-module-semantics-static-semantics-early-errors
+description: Early error when referencing privatename in constructor without being declared in class fields
+info: |
+  Static Semantics: Early Errors
+  Module : ModuleBody
+    It is a Syntax Error if AllPrivateNamesValid of ModuleBody with an empty List as an argument is false.
+features: [class-fields]
+flags: [module]
+negative:
+  phase: early
+  type: SyntaxError
+---*/
+
+throw "Test262: This statement should not be evaluated.";
+
+class C {
+  constructor() {
+    this.#x;
+  }
+}
diff --git a/test/language/module-code/privatename-not-valid-earlyerr-module-2.js b/test/language/module-code/privatename-not-valid-earlyerr-module-2.js
new file mode 100644
index 0000000000..004ba926a8
--- /dev/null
+++ b/test/language/module-code/privatename-not-valid-earlyerr-module-2.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2017 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-module-semantics-static-semantics-early-errors
+description: Early error when referencing privatename in function without declaring in class
+info: |
+  Static Semantics: Early Errors
+  Module : ModuleBody
+    It is a Syntax Error if AllPrivateNamesValid of ModuleBody with an empty List as an argument is false.
+features: [class-fields]
+flags: [module]
+negative:
+  phase: early
+  type: SyntaxError
+---*/
+
+throw "Test262: This statement should not be evaluated.";
+
+class C {
+  f() {
+    this.#x;
+  }
+}
diff --git a/test/language/module-code/privatename-not-valid-earlyerr-module-3.js b/test/language/module-code/privatename-not-valid-earlyerr-module-3.js
new file mode 100644
index 0000000000..496a5846a2
--- /dev/null
+++ b/test/language/module-code/privatename-not-valid-earlyerr-module-3.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2017 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-module-semantics-static-semantics-early-errors
+description: Early error when referencing privatename in field without being declared in class fields
+info: |
+  Static Semantics: Early Errors
+  Module : ModuleBody
+    It is a Syntax Error if AllPrivateNamesValid of ModuleBody with an empty List as an argument is false.
+features: [class-fields]
+flags: [module]
+negative:
+  phase: early
+  type: SyntaxError
+---*/
+
+throw "Test262: This statement should not be evaluated.";
+
+class C {
+  y = this.#x;
+}
diff --git a/test/language/module-code/privatename-not-valid-earlyerr-module-4.js b/test/language/module-code/privatename-not-valid-earlyerr-module-4.js
new file mode 100644
index 0000000000..055952cad1
--- /dev/null
+++ b/test/language/module-code/privatename-not-valid-earlyerr-module-4.js
@@ -0,0 +1,27 @@
+// Copyright (C) 2017 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-module-semantics-static-semantics-early-errors
+description: Early error when referencing privatename that has not been declared in class.
+info: |
+  Static Semantics: Early Errors
+  Static Semantics: Early Errors
+  Module : ModuleBody
+    It is a Syntax Error if AllPrivateNamesValid of ModuleBody with an empty List as an argument is false.
+features: [class-fields]
+flags: [module]
+negative:
+  phase: early
+  type: SyntaxError
+---*/
+
+throw "Test262: This statement should not be evaluated.";
+
+class C {
+  f() {
+    this.#x;
+    class D extends C {
+      #x;
+    }
+  }
+}
diff --git a/test/language/module-code/privatename-not-valid-earlyerr-module-5.js b/test/language/module-code/privatename-not-valid-earlyerr-module-5.js
new file mode 100644
index 0000000000..be8e95742a
--- /dev/null
+++ b/test/language/module-code/privatename-not-valid-earlyerr-module-5.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2017 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-module-semantics-static-semantics-early-errors
+description: Early error when referencing privatename outside of class
+info: |
+  Static Semantics: Early Errors
+  Module : ModuleBody
+    It is a Syntax Error if AllPrivateNamesValid of ModuleBody with an empty List as an argument is false.
+features: [class-fields]
+flags: [module]
+negative:
+  phase: early
+  type: SyntaxError
+---*/
+
+throw "Test262: This statement should not be evaluated.";
+
+class C {
+  #x;
+}
+
+new C().#x;
diff --git a/test/language/module-code/privatename-not-valid-earlyerr-module-6.js b/test/language/module-code/privatename-not-valid-earlyerr-module-6.js
new file mode 100644
index 0000000000..d2deab1fd6
--- /dev/null
+++ b/test/language/module-code/privatename-not-valid-earlyerr-module-6.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2017 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-module-semantics-static-semantics-early-errors
+description: Early error when referencing privatename outside of class.
+info: |
+  Static Semantics: Early Errors
+  Module : ModuleBody
+    It is a Syntax Error if AllPrivateNamesValid of ModuleBody with an empty List as an argument is false.
+features: [class-fields]
+flags: [module]
+negative:
+  phase: early
+  type: SyntaxError
+---*/
+
+throw "Test262: This statement should not be evaluated.";
+
+class C {}
+
+new C().#x;
diff --git a/test/language/module-code/privatename-not-valid-earlyerr-module-7.js b/test/language/module-code/privatename-not-valid-earlyerr-module-7.js
new file mode 100644
index 0000000000..360eaf61f8
--- /dev/null
+++ b/test/language/module-code/privatename-not-valid-earlyerr-module-7.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2017 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-module-semantics-static-semantics-early-errors
+description: Early error when referencing privatename on object, outside of class.
+info: |
+  Static Semantics: Early Errors
+  Module : ModuleBody
+    It is a Syntax Error if AllPrivateNamesValid of ModuleBody with an empty List as an argument is false.
+features: [class-fields]
+flags: [module]
+negative:
+  phase: early
+  type: SyntaxError
+---*/
+
+throw "Test262: This statement should not be evaluated.";
+
+obj = {};
+
+obj.#x;
diff --git a/test/language/module-code/privatename-not-valid-earlyerr-module-8.js b/test/language/module-code/privatename-not-valid-earlyerr-module-8.js
new file mode 100644
index 0000000000..a5ff8a4475
--- /dev/null
+++ b/test/language/module-code/privatename-not-valid-earlyerr-module-8.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2017 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-module-semantics-static-semantics-early-errors
+description: Early error when referencing privatename on object, outside of class.
+info: |
+  Static Semantics: Early Errors
+  Module : ModuleBody
+    It is a Syntax Error if AllPrivateNamesValid of ModuleBody with an empty List as an argument is false.
+features: [class-fields]
+flags: [module]
+negative:
+  phase: early
+  type: SyntaxError
+---*/
+
+throw "Test262: This statement should not be evaluated.";
+
+function f() {
+  this.#x;
+}
diff --git a/test/language/statements/class/privatename-not-valid-earlyerr-script-1.js b/test/language/statements/class/privatename-not-valid-earlyerr-script-1.js
new file mode 100644
index 0000000000..58419869c5
--- /dev/null
+++ b/test/language/statements/class/privatename-not-valid-earlyerr-script-1.js
@@ -0,0 +1,24 @@
+// Copyright (C) 2017 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-scripts-static-semantics-early-errors
+description: Early error when referencing privatename in constructor without being declared in class fields
+info: |
+  Static Semantics: Early Errors
+    Script : ScriptBody
+    1. Let names be an empty List.
+      ...
+    3. If AllPrivateNamesValid of ScriptBody with the argument names is false, throw a SyntaxError exception.
+features: [class-fields]
+negative:
+  phase: early
+  type: SyntaxError
+---*/
+
+throw "Test262: This statement should not be evaluated.";
+
+class C {
+  constructor() {
+    this.#x;
+  }
+}
diff --git a/test/language/statements/class/privatename-not-valid-earlyerr-script-2.js b/test/language/statements/class/privatename-not-valid-earlyerr-script-2.js
new file mode 100644
index 0000000000..e09c7009d2
--- /dev/null
+++ b/test/language/statements/class/privatename-not-valid-earlyerr-script-2.js
@@ -0,0 +1,24 @@
+// Copyright (C) 2017 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-scripts-static-semantics-early-errors
+description: Early error when referencing privatename in function in class without declaring in field
+info: |
+  Static Semantics: Early Errors
+    Script : ScriptBody
+    1. Let names be an empty List.
+      ...
+    3. If AllPrivateNamesValid of ScriptBody with the argument names is false, throw a SyntaxError exception.
+features: [class-fields]
+negative:
+  phase: early
+  type: SyntaxError
+---*/
+
+throw "Test262: This statement should not be evaluated.";
+
+class C {
+  f() {
+    this.#x;
+  }
+}
diff --git a/test/language/statements/class/privatename-not-valid-earlyerr-script-3.js b/test/language/statements/class/privatename-not-valid-earlyerr-script-3.js
new file mode 100644
index 0000000000..d857830008
--- /dev/null
+++ b/test/language/statements/class/privatename-not-valid-earlyerr-script-3.js
@@ -0,0 +1,22 @@
+// Copyright (C) 2017 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-scripts-static-semantics-early-errors
+description: Early error when referencing privatename that has not been declared in class.
+info: |
+  Static Semantics: Early Errors
+    Script : ScriptBody
+    1. Let names be an empty List.
+      ...
+    3. If AllPrivateNamesValid of ScriptBody with the argument names is false, throw a SyntaxError exception.
+features: [class-fields]
+negative:
+  phase: early
+  type: SyntaxError
+---*/
+
+throw "Test262: This statement should not be evaluated.";
+
+class C {
+  y = this.#x;
+}
diff --git a/test/language/statements/class/privatename-not-valid-earlyerr-script-4.js b/test/language/statements/class/privatename-not-valid-earlyerr-script-4.js
new file mode 100644
index 0000000000..4ad2c36632
--- /dev/null
+++ b/test/language/statements/class/privatename-not-valid-earlyerr-script-4.js
@@ -0,0 +1,27 @@
+// Copyright (C) 2017 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-scripts-static-semantics-early-errors
+description: Early error when referencing privatename that has not been declared in class.
+info: |
+  Static Semantics: Early Errors
+    Script : ScriptBody
+    1. Let names be an empty List.
+      ...
+    3. If AllPrivateNamesValid of ScriptBody with the argument names is false, throw a SyntaxError exception.
+features: [class-fields]
+negative:
+  phase: early
+  type: SyntaxError
+---*/
+
+throw "Test262: This statement should not be evaluated.";
+
+class C {
+  f() {
+    this.#x;
+    class D extends C {
+      #x;
+    }
+  }
+}
diff --git a/test/language/statements/class/privatename-not-valid-earlyerr-script-5.js b/test/language/statements/class/privatename-not-valid-earlyerr-script-5.js
new file mode 100644
index 0000000000..69c7730c8d
--- /dev/null
+++ b/test/language/statements/class/privatename-not-valid-earlyerr-script-5.js
@@ -0,0 +1,24 @@
+// Copyright (C) 2017 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-scripts-static-semantics-early-errors
+description: Early error when referencing privatename outside of class
+info: |
+  Static Semantics: Early Errors
+    Script : ScriptBody
+    1. Let names be an empty List.
+      ...
+    3. If AllPrivateNamesValid of ScriptBody with the argument names is false, throw a SyntaxError exception.
+features: [class-fields]
+negative:
+  phase: early
+  type: SyntaxError
+---*/
+
+throw "Test262: This statement should not be evaluated.";
+
+class C {
+  #x;
+}
+
+new C().#x;
diff --git a/test/language/statements/class/privatename-not-valid-earlyerr-script-6.js b/test/language/statements/class/privatename-not-valid-earlyerr-script-6.js
new file mode 100644
index 0000000000..6e48b198e0
--- /dev/null
+++ b/test/language/statements/class/privatename-not-valid-earlyerr-script-6.js
@@ -0,0 +1,22 @@
+// Copyright (C) 2017 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-scripts-static-semantics-early-errors
+description: Early error when referencing privatename outside of class.
+info: |
+  Static Semantics: Early Errors
+    Script : ScriptBody
+    1. Let names be an empty List.
+      ...
+    3. If AllPrivateNamesValid of ScriptBody with the argument names is false, throw a SyntaxError exception.
+features: [class-fields]
+negative:
+  phase: early
+  type: SyntaxError
+---*/
+
+throw "Test262: This statement should not be evaluated.";
+
+class C {}
+
+new C().#x;
diff --git a/test/language/statements/class/privatename-not-valid-earlyerr-script-7.js b/test/language/statements/class/privatename-not-valid-earlyerr-script-7.js
new file mode 100644
index 0000000000..7a70a4f7dc
--- /dev/null
+++ b/test/language/statements/class/privatename-not-valid-earlyerr-script-7.js
@@ -0,0 +1,22 @@
+// Copyright (C) 2017 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-scripts-static-semantics-early-errors
+description: Early error when referencing privatename on object, outside of class.
+info: |
+  Static Semantics: Early Errors
+    Script : ScriptBody
+    1. Let names be an empty List.
+      ...
+    3. If AllPrivateNamesValid of ScriptBody with the argument names is false, throw a SyntaxError exception.
+features: [class-fields]
+negative:
+  phase: early
+  type: SyntaxError
+---*/
+
+throw "Test262: This statement should not be evaluated.";
+
+obj = {};
+
+obj.#x;
diff --git a/test/language/statements/class/privatename-not-valid-earlyerr-script-8.js b/test/language/statements/class/privatename-not-valid-earlyerr-script-8.js
new file mode 100644
index 0000000000..40f5725963
--- /dev/null
+++ b/test/language/statements/class/privatename-not-valid-earlyerr-script-8.js
@@ -0,0 +1,22 @@
+// Copyright (C) 2017 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-scripts-static-semantics-early-errors
+description: Early error when referencing privatename on object, outside of class.
+info: |
+  Static Semantics: Early Errors
+    Script : ScriptBody
+    1. Let names be an empty List.
+      ...
+    3. If AllPrivateNamesValid of ScriptBody with the argument names is false, throw a SyntaxError exception.
+features: [class-fields]
+negative:
+  phase: early
+  type: SyntaxError
+---*/
+
+throw "Test262: This statement should not be evaluated.";
+
+function f() {
+  this.#x;
+}
diff --git a/test/language/statements/class/privatename-not-valid-eval-earlyerr-1.js b/test/language/statements/class/privatename-not-valid-eval-earlyerr-1.js
new file mode 100644
index 0000000000..8f29f20bce
--- /dev/null
+++ b/test/language/statements/class/privatename-not-valid-eval-earlyerr-1.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2017 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-scripts-static-semantics-early-errors
+description: Early error when referencing privatename in constructor without being declared in class fields
+info: |
+  Static Semantics: Early Errors
+  Script : ScriptBody
+    1. Let names be an empty List.
+    2. If Script is parsed directly from PerformEval,
+        a. Let env be the running execution context's PrivateNameEnvironment.
+        b. Repeat while env is not null,
+            i. For each binding named N in env,
+                1. If names does not contain N, append N to names.
+            ii. Let env be env's outer environment reference.
+    3. If AllPrivateNamesValid of ScriptBody with the argument names is false, throw a SyntaxError exception.
+features: [class-fields]
+---*/
+
+var executed = false;
+
+class C {
+  constructor() {
+    eval("executed = true; this.#x;");
+  }
+}
+
+assert.throws(SyntaxError, function() {
+  new C();
+});
+
+assert.sameValue(executed, false);
diff --git a/test/language/statements/class/privatename-not-valid-eval-earlyerr-2.js b/test/language/statements/class/privatename-not-valid-eval-earlyerr-2.js
new file mode 100644
index 0000000000..571b62b555
--- /dev/null
+++ b/test/language/statements/class/privatename-not-valid-eval-earlyerr-2.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2017 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-scripts-static-semantics-early-errors
+description: Early error when referencing privatename in function in class without declaring in field
+info: |
+  Static Semantics: Early Errors
+  Script : ScriptBody
+    1. Let names be an empty List.
+    2. If Script is parsed directly from PerformEval,
+        a. Let env be the running execution context's PrivateNameEnvironment.
+        b. Repeat while env is not null,
+            i. For each binding named N in env,
+                1. If names does not contain N, append N to names.
+            ii. Let env be env's outer environment reference.
+    3. If AllPrivateNamesValid of ScriptBody with the argument names is false, throw a SyntaxError exception.
+features: [class-fields]
+---*/
+
+var executed = false;
+
+class C {
+  f() {
+    eval("executed = true; this.#x;");
+  }
+}
+
+assert.throws(SyntaxError, function() {
+  new C().f();
+});
+
+assert.sameValue(executed, false);
diff --git a/test/language/statements/class/privatename-not-valid-eval-earlyerr-3.js b/test/language/statements/class/privatename-not-valid-eval-earlyerr-3.js
new file mode 100644
index 0000000000..5d0818a258
--- /dev/null
+++ b/test/language/statements/class/privatename-not-valid-eval-earlyerr-3.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2017 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-scripts-static-semantics-early-errors
+description: Early error when referencing privatename that has not been declared in class.
+info: |
+  Static Semantics: Early Errors
+  Script : ScriptBody
+    1. Let names be an empty List.
+    2. If Script is parsed directly from PerformEval,
+        a. Let env be the running execution context's PrivateNameEnvironment.
+        b. Repeat while env is not null,
+            i. For each binding named N in env,
+                1. If names does not contain N, append N to names.
+            ii. Let env be env's outer environment reference.
+    3. If AllPrivateNamesValid of ScriptBody with the argument names is false, throw a SyntaxError exception.
+features: [class-fields]
+---*/
+
+var executed = false;
+
+class C {
+  y = eval("executed = true; this.#x;")
+}
+
+assert.throws(SyntaxError, function() {
+  new C();
+});
+
+assert.sameValue(executed, false);
diff --git a/test/language/statements/class/privatename-not-valid-eval-earlyerr-4.js b/test/language/statements/class/privatename-not-valid-eval-earlyerr-4.js
new file mode 100644
index 0000000000..58ca403cce
--- /dev/null
+++ b/test/language/statements/class/privatename-not-valid-eval-earlyerr-4.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2017 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-scripts-static-semantics-early-errors
+description: Early error when referencing privatename that has not been declared in class.
+info: |
+  Static Semantics: Early Errors
+  Script : ScriptBody
+    1. Let names be an empty List.
+    2. If Script is parsed directly from PerformEval,
+        a. Let env be the running execution context's PrivateNameEnvironment.
+        b. Repeat while env is not null,
+            i. For each binding named N in env,
+                1. If names does not contain N, append N to names.
+            ii. Let env be env's outer environment reference.
+    3. If AllPrivateNamesValid of ScriptBody with the argument names is false, throw a SyntaxError exception.
+features: [class-fields]
+---*/
+
+var executed = false;
+
+class C {
+  f() {
+    eval("executed = true; this.#x;");
+    class D extends C {
+      #x;
+    }
+  }
+}
+
+assert.throws(SyntaxError, function() {
+  new C().f();
+});
+
+assert.sameValue(executed, false);
diff --git a/test/language/statements/class/privatename-not-valid-eval-earlyerr-5.js b/test/language/statements/class/privatename-not-valid-eval-earlyerr-5.js
new file mode 100644
index 0000000000..5e8ba531c0
--- /dev/null
+++ b/test/language/statements/class/privatename-not-valid-eval-earlyerr-5.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2017 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-scripts-static-semantics-early-errors
+description: Early error when referencing privatename outside of class
+info: |
+  Static Semantics: Early Errors
+  Script : ScriptBody
+    1. Let names be an empty List.
+    2. If Script is parsed directly from PerformEval,
+        a. Let env be the running execution context's PrivateNameEnvironment.
+        b. Repeat while env is not null,
+            i. For each binding named N in env,
+                1. If names does not contain N, append N to names.
+            ii. Let env be env's outer environment reference.
+    3. If AllPrivateNamesValid of ScriptBody with the argument names is false, throw a SyntaxError exception.
+features: [class-fields]
+---*/
+
+var executed = false;
+
+class C {
+  #x;
+}
+
+assert.throws(SyntaxError, function() {
+  eval("executed = true; new C().#x");
+});
+
+assert.sameValue(executed, false);
diff --git a/test/language/statements/class/privatename-not-valid-eval-earlyerr-6.js b/test/language/statements/class/privatename-not-valid-eval-earlyerr-6.js
new file mode 100644
index 0000000000..816227e67b
--- /dev/null
+++ b/test/language/statements/class/privatename-not-valid-eval-earlyerr-6.js
@@ -0,0 +1,27 @@
+// Copyright (C) 2017 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-scripts-static-semantics-early-errors
+description: Early error when referencing privatename outside of class.
+info: |
+  Static Semantics: Early Errors
+  Script : ScriptBody
+    1. Let names be an empty List.
+    2. If Script is parsed directly from PerformEval,
+        a. Let env be the running execution context's PrivateNameEnvironment.
+        b. Repeat while env is not null,
+            i. For each binding named N in env,
+                1. If names does not contain N, append N to names.
+            ii. Let env be env's outer environment reference.
+    3. If AllPrivateNamesValid of ScriptBody with the argument names is false, throw a SyntaxError exception.
+features: [class-fields]
+---*/
+
+var executed = false;
+class C {}
+
+assert.throws(SyntaxError, function() {
+  eval("executed = true; new C().#x");
+});
+
+assert.sameValue(executed, false);
diff --git a/test/language/statements/class/privatename-not-valid-eval-earlyerr-7.js b/test/language/statements/class/privatename-not-valid-eval-earlyerr-7.js
new file mode 100644
index 0000000000..f7e39c7137
--- /dev/null
+++ b/test/language/statements/class/privatename-not-valid-eval-earlyerr-7.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2017 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-scripts-static-semantics-early-errors
+description: Early error when referencing privatename on object, outside of class.
+info: |
+  Static Semantics: Early Errors
+    1. Let names be an empty List.
+      ...
+    3. If AllPrivateNamesValid of ScriptBody with the argument names is false, throw a SyntaxError exception.
+features: [class-fields]
+---*/
+
+var executed = false;
+var obj = {};
+
+assert.throws(SyntaxError, function() {
+  eval("executed = true; obj.#x;");
+});
+
+assert.sameValue(executed, false);
diff --git a/test/language/statements/class/privatename-not-valid-eval-earlyerr-8.js b/test/language/statements/class/privatename-not-valid-eval-earlyerr-8.js
new file mode 100644
index 0000000000..8ffdc42deb
--- /dev/null
+++ b/test/language/statements/class/privatename-not-valid-eval-earlyerr-8.js
@@ -0,0 +1,25 @@
+// Copyright (C) 2017 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-scripts-static-semantics-early-errors
+description: Early error when referencing privatename on object, outside of class.
+info: |
+  Static Semantics: Early Errors
+    1. Let names be an empty List.
+      ...
+    3. If AllPrivateNamesValid of ScriptBody with the argument names is false, throw a SyntaxError exception.
+features: [class-fields]
+---*/
+
+var executed = false;
+
+function f() {
+  eval("executed = true; this.#x;");
+}
+
+assert.throws(SyntaxError, function() {
+  f();
+});
+
+assert.sameValue(executed, false);
+
-- 
GitLab