summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/expressions/optional-chain-tdz.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/non262/expressions/optional-chain-tdz.js')
-rw-r--r--js/src/tests/non262/expressions/optional-chain-tdz.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/js/src/tests/non262/expressions/optional-chain-tdz.js b/js/src/tests/non262/expressions/optional-chain-tdz.js
new file mode 100644
index 0000000000..e12d0fb860
--- /dev/null
+++ b/js/src/tests/non262/expressions/optional-chain-tdz.js
@@ -0,0 +1,28 @@
+// Test TDZ for optional chaining.
+
+// TDZ for lexical |let| bindings with optional chaining.
+{
+ assertThrowsInstanceOf(() => {
+ const Null = null;
+ Null?.[b];
+ b = 0;
+ let b;
+ }, ReferenceError);
+
+ assertThrowsInstanceOf(() => {
+ const Null = null;
+ Null?.[b]();
+ b = 0;
+ let b;
+ }, ReferenceError);
+
+ assertThrowsInstanceOf(() => {
+ const Null = null;
+ delete Null?.[b];
+ b = 0;
+ let b;
+ }, ReferenceError);
+}
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);