Skip to content

Truly independent web browser

Tests/LibJS: Test reading arguments before its lexical declaration

Shannon Boothb33d4478cad2
diff --git a/Tests/LibJS/Runtime/arguments-object.js b/Tests/LibJS/Runtime/arguments-object.js
index 50328a70b1d..b67d65636d4 100644
--- a/Tests/LibJS/Runtime/arguments-object.js
+++ b/Tests/LibJS/Runtime/arguments-object.js
@@ -368,6 +368,30 @@ test("lexical declaration named arguments takes the place of the arguments objec
expect(laterBindingsStayDeclared()).toEqual(["ReferenceError", 2]);
});
+test("lexical declaration named arguments is uninitialized until it is declared", () => {
+ function letDeclaration() {
+ arguments;
+ let arguments;
+ }
+ function constDeclaration() {
+ arguments;
+ const arguments = 1;
+ }
+ function destructuringDeclaration() {
+ arguments;
+ let [arguments] = [];
+ }
+ function usingDeclaration() {
+ arguments;
+ using arguments = null;
+ }
+
+ expect(letDeclaration).toThrow(ReferenceError);
+ expect(constDeclaration).toThrow(ReferenceError);
+ expect(destructuringDeclaration).toThrow(ReferenceError);
+ expect(usingDeclaration).toThrow(ReferenceError);
+});
+
test("mapped arguments object in the strict code of a class", () => {
function computedKey(first) {
class C {