1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 08:35:09 +00:00

LibJS: Don't extend arguments object to match the parameter count

The `arguments` object should only have the *arguments* as numeric
properties, not the *parameters*.

Given this function:

    function foo(a, b) {
        return arguments.length;
    }

Calling foo() with no arguments now correctly returns 0 instead of 2.
This commit is contained in:
Andreas Kling 2021-06-27 00:37:07 +02:00
parent beb43f673e
commit f61a9f2dc5

View file

@ -170,9 +170,6 @@ Value ScriptFunction::execute_function_body()
argument_value = js_undefined();
}
if (i >= execution_context_arguments.size())
execution_context_arguments.resize(i + 1);
execution_context_arguments[i] = argument_value;
vm.assign(param, argument_value, global_object(), true, vm.lexical_environment());
});