LibJS: Function.length respects default and rest parameters

"[Function.length is] the number of formal parameters. This number
excludes the rest parameter and only includes parameters before
the first one with a default value." - MDN
This commit is contained in:
Matthew Olsson 2020-05-05 20:02:14 -07:00 committed by Andreas Kling
commit 838390171c
Notes: sideshowbarker 2024-07-19 06:55:56 +09:00
6 changed files with 43 additions and 15 deletions

View file

@ -70,14 +70,14 @@ Value ScopeNode::execute(Interpreter& interpreter) const
Value FunctionDeclaration::execute(Interpreter& interpreter) const
{
auto* function = ScriptFunction::create(interpreter.global_object(), name(), body(), parameters(), interpreter.current_environment());
auto* function = ScriptFunction::create(interpreter.global_object(), name(), body(), parameters(), function_length(), interpreter.current_environment());
interpreter.set_variable(name(), function);
return js_undefined();
}
Value FunctionExpression::execute(Interpreter& interpreter) const
{
return ScriptFunction::create(interpreter.global_object(), name(), body(), parameters(), interpreter.current_environment());
return ScriptFunction::create(interpreter.global_object(), name(), body(), parameters(), function_length(), interpreter.current_environment());
}
Value ExpressionStatement::execute(Interpreter& interpreter) const